internal RemotePeer(P2PGroup group, ProudSession session, Crypt crypt) { Group = group; HostId = session.HostId; Crypt = crypt; ConnectionStates = new ConcurrentDictionary <uint, P2PConnectionState>(); Session = session; }
public void AddSession(TKey key, ProudSession session) { if (!_sessions.TryAdd(key, session)) { throw new ProudException($"Session {key} is already registered"); } _schedulerService.Execute( (This, s) => ((SessionManager <TKey>)This).OnAdded((ProudSession)s), this, session ); }
public void Send(ProudSession session, CoreMessage message) { using (var ms = new PooledMemoryStream(_pipe.Service.ArrayPool)) using (var w = new BinaryWriter(ms)) { var @out = _protocol.Serialize(session, message); using (var ms2 = new PooledMemoryStream(_pipe.Service.ArrayPool)) { @out.Serialize(ms2); var segment = ms2.ToSegment(); w.Write((ushort)43981); w.Write((ushort)0); w.Write(segment.Count); w.Write(0); w.Write(0); w.Write(segment.Array, segment.Offset, segment.Count); segment = ms.ToSegment(); _socket.SendTo(segment.Array, segment.Offset, segment.Count, SocketFlags.None, session.UdpEndPoint); } } }
public ErrorEventArgs(ProudSession session, Exception exception) { Session = session; Exception = exception; }
protected virtual void OnDisconnected(ProudSession session) { Disconnected?.Invoke(this, session); }
internal void AddSession(ProudSession session) { Configuration.Logger?.Debug("Adding new session {HostId}", session.HostId); _sessions[session.HostId] = session; OnConnected(session); }
public SessionEventArgs(ProudSession session) { Session = session; }
protected virtual void OnRemoved(ProudSession session) { Removed?.Invoke(this, new SessionEventArgs(session)); }
internal void RemoveSession(ProudSession session) { _sessions.Remove(session.HostId); SessionsByUdpId.Remove(session.UdpSessionId); OnDisconnected(session); }
internal void AddSession(ProudSession session) { _sessions[session.HostId] = session; OnConnected(session); }