Example #1
0
 public BaseRouterIO(IDeltaLogger baseLogger, IRouterTransport transport, MinorMajorVersionPair appVersion)
 {
     this.baseLogger         = baseLogger;
     this.transport          = transport;
     this.appVersion         = appVersion;
     outgoingMessageId       = new Random().Next(1, int.MaxValue - 1);
     receivingPackets        = new Dictionary <ulong, RouterMessage>();
     waitingResponseSessions = new ConcurrentDictionary <int, Channel <RouterMessage> >();
 }
 public MasterControlServer(IDeltaLogger logger, IPEndPoint listenEndpoint)
 {
     this.logger = logger;
     io          = new ServerRouterIO <MasterControlClient>(logger, new UnencryptedTransport(), new MinorMajorVersionPair(Program.APP_VERSION_MAJOR, Program.APP_VERSION_MINOR), listenEndpoint, (IServerRouterIO server, Socket sock) =>
     {
         return(new MasterControlClient(server, sock));
     });
     io.OnClientConnected += Io_OnClientConnected;
     io.OnClientDropped   += Io_OnClientDropped;
     io.OnClientMessage   += Io_OnClientMessage;
 }
Example #3
0
 public RouterServer(ManagerSession session)
 {
     //Open IO
     this.session   = session;
     this.logger    = session;
     listenEndpoint = new IPEndPoint(IPAddress.Loopback, session.private_port);
     io             = new ServerRouterIO <RouterSession>(logger, new UnencryptedTransport(), new MinorMajorVersionPair(Program.APP_VERSION_MAJOR, Program.APP_VERSION_MINOR), listenEndpoint, (IServerRouterIO server, Socket sock) =>
     {
         return(new RouterSession(server, sock));
     });
     io.OnClientConnected += Io_OnClientConnected;
     io.OnClientDropped   += Io_OnClientDropped;
     io.OnClientMessage   += Io_OnClientMessage;
 }
Example #4
0
        public ClientRouterIO(IDeltaLogger logger, IRouterTransport transport, MinorMajorVersionPair libVersion, IPEndPoint routerEndpoint) : base(logger, transport, libVersion)
        {
            this.routerEndpoint = routerEndpoint;
            outgoingPackets     = new ConcurrentQueue <RouterPacket>();
            handlingMessages    = new ConcurrentQueue <RouterMessage>();

            //Create net worker
            netWorkerThread = new Thread(RunNetWorkerThread);
            netWorkerThread.IsBackground = true;
            netWorkerThread.Start();

            //Create handler worker
            handlerWorkingThread = new Thread(RunHandlerThread);
            handlerWorkingThread.IsBackground = true;
            handlerWorkingThread.Start();
        }
Example #5
0
        public ServerRouterIO(IDeltaLogger baseLogger, IRouterTransport transport, MinorMajorVersionPair appVersion, IPEndPoint bindAddr, RouterServerMakeClient <T> funcConstructClient)
        {
            this.baseLogger          = baseLogger;
            this.transport           = transport;
            this.appVersion          = appVersion;
            this.funcConstructClient = funcConstructClient;
            connectedClients         = new List <T>();
            queuedOutgoingPackets    = new ConcurrentQueue <Tuple <T, RouterPacket> >();

            //Spin up worker therad
            workerThread = new Thread(OutgoingQueueWorkerThread);
            workerThread.IsBackground = true;
            workerThread.Start();

            //Open server
            serverSock = new Socket(SocketType.Stream, ProtocolType.Tcp);
            serverSock.Bind(bindAddr);
            serverSock.Listen(10);
            serverSock.BeginAccept(ClientAccepted, null);
        }