public SocketIOServer(SocketIOServerOption Option) { Server = new EngineIOServer(this.Option = Option); Server.OnConnection(OnConnection); AckManager.SetTimeout(Option.PingTimeout); }
public async Task <IActionResult> PrimusEIO(string transport, string sid) { if (PrimusClient.SocketType == SocketTypeEnum.ENGINE_IO) { return(await EngineIOServer.CheckWebsocketContext(HttpContext, transport, sid)); } return(Json(string.Empty)); }
internal EngineIOSocket(string SID, EngineIOServer Server, EngineIOTransport Transport) { this.SID = SID; this.Server = Server; Upgrading = false; Upgraded = false; ReadyState = EngineIOReadyState.OPENING; SetTransport(Transport); OnOpen(); }
static void Main(string[] args) { //EngineIOLogger.DoWrite = false; using (EngineIOServer server = new EngineIOServer(new EngineIOServerOption(1009))) { Console.WriteLine("Listening on " + server.Option.Port); server.OnConnection((socket) => { Console.WriteLine("Client connected!"); socket.OnMessage((packet) => { Console.WriteLine(packet.Data); if (packet.IsText) { socket.Send(packet.Data); } else { socket.Send(packet.RawData); } }); socket.OnClose(() => { Console.WriteLine("Client disconnected!"); }); socket.Send(new byte[] { 0, 1, 2, 3, 4, 5, 6 }); }); server.Start(); Console.WriteLine("Input /exit to exit program."); string line; while (!(line = Console.ReadLine())?.Trim()?.ToLower()?.Equals("/exit") ?? false) { server.Broadcast(line); } } Console.WriteLine("Press enter to continue..."); Console.Read(); }