• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 Esmertec AG.
3  * Copyright (C) 2008 The Android Open Source Project
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 package com.android.im.engine;
18 
19 public interface HeartbeatService {
20     public interface Callback {
21         /**
22          * Called on heartbeat schedule.
23          *
24          * @return the offset in milliseconds that the method wants to
25          * be called the next time. Return 0 or negative value indicates to stop
26          * the schedule of this callback.
27          */
sendHeartbeat()28         public long sendHeartbeat();
29     }
30 
31     /**
32      * Start to schedule a heartbeat operation.
33      *
34      * @param callback The operation wants to be called repeat.
35      * @param triggerTime The time(in milliseconds) until the operation
36      *            will be executed the first time.
37      */
startHeartbeat(Callback callback, long triggerTime)38     public void startHeartbeat(Callback callback, long triggerTime);
39 
40     /**
41      * Stop scheduling a heartbeat operation.
42      *
43      * @param callback The operation will be stopped.
44      */
stopHeartbeat(Callback callback)45     public void stopHeartbeat(Callback callback);
46 }
47