예제 #1
0
        public override void Go()
        {
            var server = new MessagingServer.Server(S);
            //server.Inject(new WebSocketServer.ServerExtension());

            var managerExt = new ManagerServiceExtension();

            managerExt.Main(S);

            server.Start();
        }
예제 #2
0
 public TcpSocketClient(MessagingServer.Server messagingServer)
 {
     _dataProvider    = new CommonJsonDataProvider(messagingServer);
     _messagingServer = messagingServer;
 }
예제 #3
0
 public void Start(MessagingServer.Server server)
 {
     ServerInstance = new Server(new SocketServerContext(server));
     ServerInstance.Start();
 }
예제 #4
0
파일: Program.cs 프로젝트: renwoox/prime
        static void Main(string[] args)
        {
            var logger = new ConsoleLogger()
            {
                IncludePreamble = true
            };

            logger.Log("Operating system: " + Environment.OSVersion.Platform);
            logger.Log("Current directory: " + Environment.CurrentDirectory);

            logger.Log("Prime.Manager started");

            var serverContext = new ServerContext()
            {
                L = logger
            };

            var messagingServer = new MessagingServer.Server(serverContext);
            var clientExcension = new SocketClient.ServerExtension();

            messagingServer.Inject(clientExcension);

            messagingServer.Start();

            var managerExtension = new ManagerServiceExtension();

            managerExtension.Main(serverContext);

            Console.ReadLine();

            //////////////// OLD /////////////

            //var logger = new ConsoleLogger() { IncludePreamble = true };

            //logger.Log("Operating system: " + Environment.OSVersion.Platform);
            //logger.Log("Current directory: " + Environment.CurrentDirectory);

            //logger.Log("Prime.Manager started");

            //var client = new System.Net.Sockets.Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            //logger.Log("Establishing connection to local socket server.");
            //client.Connect("127.0.0.1", 9991);

            //// TODO: Alyasko: implement TCP client here.

            ////var server = new MessagingServer.Server();

            //var settings = new JsonSerializerSettings()
            //{
            //    TypeNameHandling = TypeNameHandling.Objects,
            //    //SerializationBinder = server.TypeBinder
            //};

            //var dataString = "";//JsonConvert.SerializeObject(msg, settings);

            //logger.Log("Connection established, sending message: " + dataString);

            //var dataBytes = dataString.GetBytes();

            //client.Send(dataBytes);

            //Task.Run(() =>
            //{
            //    var helper = new MessageTypedSender(null); // TODO: Alyasko: fix this.

            //    do
            //    {
            //        var buffer = new byte[1024];
            //        var iRx = client.Receive(buffer);
            //        var recv = buffer.GetString().Substring(0, iRx);

            //        if (string.IsNullOrWhiteSpace(recv))
            //            continue;

            //        if (JsonConvert.DeserializeObject(recv, settings) is BaseTransportMessage m)
            //            helper.UnPackSendReceivedMessage(new ExternalMessage(m.SessionId, m));

            //    } while (client.Connected);
            //});

            //Console.ReadLine();
        }
예제 #5
0
 public WebSocketServerContext(MessagingServer.Server server, IPAddress ipAddress, short port)
 {
     MessageServer = server;
     IpAddress     = ipAddress;
     Port          = port;
 }
예제 #6
0
 public WebSocketServerContext(MessagingServer.Server server) : this(server, IPAddress.Any, 9992)
 {
     MessageServer = server;
 }
예제 #7
0
 public SocketServerContext(MessagingServer.Server server)
 {
     MessagingServer = server;
     ServerContext   = server.ServerContext;
 }
예제 #8
0
 public SocketServerContext(MessagingServer.Server server, IPAddress ipAddress, short portNumber) : this(server)
 {
     IpAddress  = ipAddress;
     PortNumber = portNumber;
 }
예제 #9
0
 public SocketClientContext(MessagingServer.Server messagingServer, IPEndPoint ipEndPoint)
 {
     MessagingServer = messagingServer;
     IpEndPoint      = ipEndPoint;
 }