private void RunWs(MessagingServer.Server server, ServerContext sctx) { var manager = new ManagerServiceExtension(); manager.Main(sctx); var wsServerExt = new Prime.WebSocketServer.ServerExtension(); server.Inject(wsServerExt); wsServerExt.Start(server); }
public override void Go() { var server = new MessagingServer.Server(S); //server.Inject(new WebSocketServer.ServerExtension()); var managerExt = new ManagerServiceExtension(); managerExt.Main(S); server.Start(); }
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(); }