static void Main(string[] args) { FileStream fs1 = new FileStream("out.bin",FileMode.Create,FileAccess.Write,FileShare.Read); FileStream fs2 = new FileStream("out2.bin",FileMode.Create,FileAccess.Write,FileShare.Read); bf1 = new BufferedStream(fs1); bf2 = new BufferedStream(fs2); try { Server server = new Server(10, 4096* 100 * 2); server.Sequential = false; server.Start(new IPEndPoint(IPAddress.Any, 40004)); server.MessageReceived += OnMessageReceived; server.ClientConnected += OnClientConnected; server.ClientDisconnected += OnClientDisconnected; Console.ReadKey(); } finally { bf1.Flush(); bf2.Flush(); bf1.Close(); bf2.Close(); fs1.Close(); fs2.Close(); } }
/// <summary> /// Initializes the manager /// </summary> public static void Init() { PluginManager.PluginUnload += PluginManager_PluginUnload; _debugChannel = Debug.AddChannel("com.projectgame.plugin.networkmanager"); Debug.Log(_debugChannel, "Starting Server"); _server = new Server(); _server.Start(); Server.ClientConnected += Server_ClientConnected; Server.ClientDisconnected += Server_CliendDisconnected; Server.MessageReceived += Server_MessageReceived; }