コード例 #1
0
 protected NetState(NetPump messagePump)
 {
     _MessagePump       = messagePump;
     _NextCheckActivity = Timing.Ticks + MsBeforeDisconnectFirst;
     _Buffer            = new ByteQueue();
     _RecvBuffer        = _ReceiveBufferPool.AcquireBuffer();
     _SendQueue         = new SendQueue();
     Instances.Add(this);
     ConnectedOn = DateTime.UtcNow;
 }
コード例 #2
0
ファイル: NetStateTcp.cs プロジェクト: ZaneDubya/Monolith
 public NetStateTcp(Socket socket, NetPump messagePump)
     : base(messagePump)
 {
     _Socket      = socket;
     _IsConnected = false;
     try {
         Address    = (((IPEndPoint)_Socket.RemoteEndPoint).Address);
         Port       = ((IPEndPoint)_Socket.RemoteEndPoint).Port;
         ServerPort = ((IPEndPoint)_Socket.LocalEndPoint).Port;
         _ToString  = $"{Address.ToString()}:{Port:X4}";
         Kernel.WriteLine(TypeName, $"{this} connected to *:{ServerPort} [{NetState.Instances.Count} Online]");
     }
     catch (Exception ex) {
         Kernel.WriteLine(TypeName, $"{this} failed to connect to *:{ServerPort} [{NetState.Instances.Count} Online]");
         TraceException(ex);
         Address   = IPAddress.None;
         Port      = 0;
         _ToString = "(error)";
     }
 }
コード例 #3
0
ファイル: NetStateUdp.cs プロジェクト: ZaneDubya/Monolith
 public NetStateUdp(Socket socket, IPEndPoint localEP, IPEndPoint remoteEP, NetPump messagePump)
     : base(messagePump)
 {
     _NextCheckActivity = Timing.Ticks + MsBeforeDisconnectFirst;
     _ClientEndPoint    = remoteEP;
     try {
         Address    = _ClientEndPoint.Address;
         Port       = _ClientEndPoint.Port;
         ServerPort = localEP.Port;
         _Socket    = socket;
         _ToString  = $"{Address.ToString()}:{Port:X4}";
         Kernel.WriteLine(TypeName, $"{this} connected to *:{ServerPort} [{NetState.Instances.Count} Online]");
     }
     catch (Exception ex) {
         Kernel.WriteLine(TypeName, $"{this} failed to connect to *:{ServerPort} [{NetState.Instances.Count} Online]");
         TraceException(ex);
         Port      = 0;
         _ToString = "(error)";
     }
 }