public override void OnOpen() { base.OnOpen(); AddClient(this); string key = GetClientKey(this); ExecuteHandler(HandlerType.OnOpen, new Object[] { key }); OnSessionConnected?.Invoke(key); }
private void OnWsSessionConnected(object sender, ConnectionEventArgs e) { if (OnSessionConnected == null) { _logger?.LogDebug("WebSocket session [{id}] connected!", e.SessionId); } else { OnSessionConnected?.Invoke(sender, e); } }
private async Task HandleSession(ServerSession session) { _sessionManager.InsertSession(session); try { _logger.LogInformation($"A new session connected: {session.SessionId}"); session.OnSessionConnected(); OnSessionConnected?.Invoke(session); try { await session.RunAsync(); } catch (Exception e) { _logger.LogError(e, $"Failed to handle the session {session.SessionId}."); session.Close(); } if (_udpSocket != null) { _udpSocket.RemoveSession(session); } _logger.LogInformation($"The session disconnected: {session.SessionId}"); OnSessionClosed?.Invoke(session); await session.OnSessionClosed(); } catch (Exception e) { _logger.LogError(e, $"Failed to handle the session {session.SessionId}."); } finally { _sessionManager.RemoveSession(session); _sessionFactory.Release(session); } }
public void InstallEvents(bool server) { Dispatch.Install <SteamRemotePlaySessionConnected_t>(x => OnSessionConnected?.Invoke(x.SessionID), server); Dispatch.Install <SteamRemotePlaySessionDisconnected_t>(x => OnSessionDisconnected?.Invoke(x.SessionID), server); }
public override void OnOpen(string connectionGUID, System.Net.WebSockets.WebSocket socket) { WebSocketConnectionManager.AddSocket(connectionGUID, socket); ExecuteHandler(HandlerType.OnOpen, new Object[] { connectionGUID }); OnSessionConnected?.Invoke(connectionGUID); }
/// <summary> /// Handle session connected notification /// </summary> /// <param name="session">Connected session</param> protected virtual void OnConnected(WsSession session) { OnSessionConnected?.Invoke(session, new ConnectionEventArgs(session.Id)); }
/// <summary> /// 连接事件处理器 /// </summary> /// <param name="session"></param> private void SocketServer_NewSessionConnected(SuperSocket.SocketBase.AppSession session) { ClientsIPEndPoint.Add(session.RemoteEndPoint); LogHelper.Logger.Info($"SocketServer_NewSessionConnected,SessionID:{session.SessionID}"); OnSessionConnected?.Invoke(this, new ConnectEventArgs(session.RemoteEndPoint)); }
private void ProcessEvent() { if (isEvent) { switch (eventTypeString) { case "LoginStateChangeEvent": OnLoginStateChange?.Invoke(cookie, accountHandle, statusCode, statusString, state); break; case "SessionNewEvent": OnNewSession?.Invoke(cookie, accountHandle, eventSessionHandle, state, nameString, uriString); break; case "SessionStateChangeEvent": OnSessionStateChange?.Invoke(cookie, uriString, statusCode, statusString, eventSessionHandle, state, isChannel, nameString); break; case "ParticipantStateChangeEvent": OnParticipantStateChange?.Invoke(cookie, uriString, statusCode, statusString, state, nameString, displayNameString, participantType); break; case "ParticipantPropertiesEvent": OnParticipantProperties?.Invoke(cookie, uriString, statusCode, statusString, isLocallyMuted, isModeratorMuted, isSpeaking, volume, energy); break; case "AuxAudioPropertiesEvent": OnAuxAudioProperties?.Invoke(cookie, energy); break; } } else { switch (actionString) { case "Connector.Create.1": OnConnectorCreated?.Invoke(cookie, statusCode, statusString, connectorHandle); break; case "Account.Login.1": OnLogin?.Invoke(cookie, statusCode, statusString, accountHandle); break; case "Session.Create.1": OnSessionCreated?.Invoke(cookie, statusCode, statusString, sessionHandle); break; case "Session.Connect.1": OnSessionConnected?.Invoke(cookie, statusCode, statusString); break; case "Session.Terminate.1": OnSessionTerminated?.Invoke(cookie, statusCode, statusString); break; case "Account.Logout.1": OnAccountLogout?.Invoke(cookie, statusCode, statusString); break; case "Connector.InitiateShutdown.1": OnConnectorInitiateShutdown?.Invoke(cookie, statusCode, statusString); break; case "Account.ChannelGetList.1": OnAccountChannelGetList?.Invoke(cookie, statusCode, statusString); break; case "Aux.GetCaptureDevices.1": OnCaptureDevices?.Invoke(cookie, statusCode, statusString, nameString); break; case "Aux.GetRenderDevices.1": OnRenderDevices?.Invoke(cookie, statusCode, statusString, nameString); break; } } }