Класс DeviceLoginManager:
Код: Выделить всё
public static OnlineDevice[] GetOnlineDevices() //error
{
List online = new List();
foreach(Guid guid in SessionRegistry.GetKeys())
{
if (SessionRegistry.GetSession(guid).loggedIn)
{
online.Add(new OnlineDevice { session = SessionRegistry.GetSession(guid) });
}
const int KeepAliveTimeout = 10 * 60 * 1000;
SBWebSocketHandler aSession = SessionRegistry.GetSession(guid);
if (aSession.keepAliveMsgSupported &&
aSession.keepAliveRecvedTime < Environment.TickCount - KeepAliveTimeout)
{
aSession.Close();
}
}
return online.ToArray();
}
Код: Выделить всё
internal static object _monitor = new object(); internal static Dictionary _sessions = new Dictionary(); private static RandomNumberGenerator _random = RandomNumberGenerator.Create(); /// /// Retrieves an open session from its ID. /// ///
Session ID /// A session object if matching ID was found; otherwise null public static SBWebSocketHandler GetSession(Guid guid) { lock (_monitor) { SBWebSocketHandler result; if (_sessions.TryGetValue(guid, out result)) return result; else { // return null; throw new WebDeviceException("Invalid session ID. The session may have been already closed."); } } } internal static Guid AddSession(SBWebSocketHandler handler) { lock (_monitor) { byte[] guidBytes = new byte[16]; Guid guid; do { _random.GetBytes(guidBytes); guid = new Guid(guidBytes); } while (_sessions.ContainsKey(guid)); _sessions.Add(guid, handler); return guid; } } public static Dictionary.KeyCollection GetKeys() { lock (_monitor) { return _sessions.Keys; } }
private IDeviceLoginManager _loginManager;
public Guid SessionId { get { return m_guid; }
публичное переопределение void OnOpen()
{
Код: Выделить всё
_loginManager = (IDeviceLoginManager)
Type.GetType(ConfigurationManager.AppSettings["smackbio.websocketsdk.deviceLoginManager"])
.GetConstructor(new Type[0])
.Invoke(new object[0]);
m_guid = SessionRegistry.AddSession(this);
registerMsgRecved = false;
loggedIn = false;
keepAliveMsgSupported = false;

< img alt="введите здесь описание изображения" src="https://i.sstatic.net/eAATc7Uv.png" />
[img]https://i .sstatic.net/EDbDMKZP.png[/img]

Подробнее здесь: https://stackoverflow.com/questions/790 ... ady-closed
Мобильная версия