Esempio n. 1
0
 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
                );
        }
Esempio n. 3
0
        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;
 }
Esempio n. 5
0
 protected virtual void OnDisconnected(ProudSession session)
 {
     Disconnected?.Invoke(this, session);
 }
Esempio n. 6
0
 internal void AddSession(ProudSession session)
 {
     Configuration.Logger?.Debug("Adding new session {HostId}", session.HostId);
     _sessions[session.HostId] = session;
     OnConnected(session);
 }
Esempio n. 7
0
 public SessionEventArgs(ProudSession session)
 {
     Session = session;
 }
 protected virtual void OnRemoved(ProudSession session)
 {
     Removed?.Invoke(this, new SessionEventArgs(session));
 }
Esempio n. 9
0
 internal void RemoveSession(ProudSession session)
 {
     _sessions.Remove(session.HostId);
     SessionsByUdpId.Remove(session.UdpSessionId);
     OnDisconnected(session);
 }
Esempio n. 10
0
 internal void AddSession(ProudSession session)
 {
     _sessions[session.HostId] = session;
     OnConnected(session);
 }