public UdpSession(UdpServer Server, Socket ServerSocket, IPEndPoint RemoteEndPoint, Func <ISessionContext, IBinaryTransformer, KeyValuePair <IServerImplementation, IStreamedVirtualTransportServer> > VirtualTransportServerFactory, Action <Action> QueueUserWorkItem) { this.Server = Server; this.ServerSocket = ServerSocket; this.RemoteEndPoint = RemoteEndPoint; this.LastActiveTimeValue = new LockedVariable <DateTime>(DateTime.UtcNow); ssm = new SessionStateMachine <StreamedVirtualTransportServerHandleResult, Unit>(ex => ex is SocketException, OnCriticalError, OnShutdownRead, OnShutdownWrite, OnWrite, OnExecute, OnStartRawRead, OnExit, QueueUserWorkItem); Context = Server.ServerContext.CreateSessionContext(); Context.Quit += ssm.NotifyExit; Context.Authenticated += () => Server.NotifySessionAuthenticated(this); var rpst = new Rc4PacketServerTransformer(); var Pair = VirtualTransportServerFactory(Context, rpst); si = Pair.Key; vts = Pair.Value; Context.SecureConnectionRequired += c => { rpst.SetSecureContext(c); NextSecureContext = c; }; vts.ServerEvent += () => ssm.NotifyWrite(new Unit()); vts.InputByteLengthReport += (CommandName, ByteLength) => Server.ServerContext.RaiseSessionLog(new SessionLogEntry { Token = Context.SessionTokenString, RemoteEndPoint = RemoteEndPoint, Time = DateTime.UtcNow, Type = "InBytes", Name = CommandName, Message = ByteLength.ToInvariantString() }); vts.OutputByteLengthReport += (CommandName, ByteLength) => Server.ServerContext.RaiseSessionLog(new SessionLogEntry { Token = Context.SessionTokenString, RemoteEndPoint = RemoteEndPoint, Time = DateTime.UtcNow, Type = "OutBytes", Name = CommandName, Message = ByteLength.ToInvariantString() }); }
public GcServer(IServerImplementation implementation, ILogger logger) { _logger = logger; var fact = new LoggerFactory(); fact.CreateLogger <GcServer>(); _peers = new ConcurrentDictionary <int, GcPeer>(); _peersByConnectionId = new ConcurrentDictionary <int, GcPeer>(); _relayConnections = new ConcurrentDictionary <int, GcConnection>(); _messageHandlers = new Dictionary <short, MessageHandler>(); Implementation = implementation; implementation.RawDataReceived += OnRawDataReceived; implementation.ConnectionReceived += OnConnectionReceived; implementation.ConnectionLost += OnConnectionLost; SetHandler((short)InternalOpCodes.EstablishPeer, HandleEstablishPeer); }
public HttpSession(HttpServer Server, IPEndPoint RemoteEndPoint, Func <ISessionContext, KeyValuePair <IServerImplementation, IHttpVirtualTransportServer> > VirtualTransportServerFactory, Action <Action> QueueUserWorkItem) { this.Server = Server; this.RemoteEndPoint = RemoteEndPoint; this.LastActiveTimeValue = new LockedVariable <DateTime>(DateTime.UtcNow); ssm = new SessionStateMachine <HttpVirtualTransportServerHandleResult, Unit>(ex => false, OnCriticalError, OnShutdownRead, OnShutdownWrite, OnWrite, OnExecute, OnStartRawRead, OnExit, QueueUserWorkItem); Context = Server.ServerContext.CreateSessionContext(); Context.Quit += ssm.NotifyExit; Context.Authenticated += () => Server.NotifySessionAuthenticated(this); Context.SecureConnectionRequired += c => { throw new NotImplementedException(); }; var Pair = VirtualTransportServerFactory(Context); si = Pair.Key; vts = Pair.Value; }
public Server(IServerImplementation server) { _server = server; }