Other Events
Less than 1 minute
Connection Callbacks
Description
Callbacks when the long connection is established, or lost.
Callbacks
void ConnectionClosed() // Connection closed
void ConnectAck() // connected
void ConnectionKickout(int errorCode, string errorMsg) // connection is kicked out by another connection
void HearBeat(string heartBeatContent) // connection heartbeat
Example
public class DefaultApiComposeCallback : IApiComposeCallback
{
public DefaultApiComposeCallback()
{
}
void IApiComposeCallback.ConnectionAck()
{
ApiLogger.Info("connect success.");
}
void IApiComposeCallback.ConnectionAck(int serverSendInterval, int serverReceiveInterval)
{
ApiLogger.Info($"connect success. serverSendInterval:{serverSendInterval}," +
$" serverReceiveInterval:{serverReceiveInterval}");
}
void IApiComposeCallback.HearBeat(string heartBeatContent)
{
ApiLogger.Info("HearBeat:" + heartBeatContent);
}
void IApiComposeCallback.ServerHeartBeatTimeOut(string channelId)
{
ApiLogger.Warn("ServerHeartBeatTimeOut:" + channelId);
}
void IApiComposeCallback.ConnectionClosed()
{
ApiLogger.Info("connection closed.");
}
void IApiComposeCallback.ConnectionKickout(int errorCode, string errorMsg)
{
ApiLogger.Info($"ConnectionKickout, errorCode:{errorCode}, errorMsg:{errorMsg}");
}
}
Error
Description
Callback when an error occurs
Callbacks
void Error(string errorMsg)
void Error(int id, int errorCode, string errorMsg)
Example
public class DefaultApiComposeCallback : IApiComposeCallback
{
public DefaultApiComposeCallback()
{
}
void IApiComposeCallback.Error(string errorMsg)
{
ApiLogger.Error("receive error:" + errorMsg);
}
void IApiComposeCallback.Error(int id, int errorCode, string errorMsg)
{
ApiLogger.Error($"receive error, id:{id}, errorCode:{errorCode}, errorMsg:{errorMsg}");
}
}