public override void ServerStart() { m_Server?.Dispose(); ServerConfig config; if (!string.IsNullOrWhiteSpace(m_RsaXmlPath)) { var xml = Resources.Load <TextAsset>(m_RsaXmlPath); config = ServerConfig.FromXML(xml.text, m_Port); } else { config = ServerConfig.Create(m_Port); } m_Server = Connection.StartServer(config); m_Server.OnPeerEvent += (e) => { switch (e.EventType) { case PeerEvent.Type.Add: OnServerConnected?.Invoke(Mathf.Abs(e.Peer.ConnectionId)); break; case PeerEvent.Type.Remove: OnServerDisconnected?.Invoke(Mathf.Abs(e.Peer.ConnectionId)); break; } }; }
public static void StartServer4(IPEndPoint ipep) { KcpServer.KcpSetting.Default.RTO = 1; KcpServer.KcpSetting.Default.NoDelay = 1; KcpServer.KcpSetting.Default.NoDelayInterval = 1; KcpServer.KcpSetting.Default.NoDelayResend = 10; KcpServer.KcpSetting.Default.NoDelayNC = 1; KcpServer.KcpSetting.Default.RecWindowSize = 1024; KcpServer.KcpSetting.Default.SndWindowSize = 1024; KcpServer.KcpSetting.Default.MTU = Utilities.PackSettings.MAX_DATA_LEN; Server = new UdpServerLite(); App = new TestApplication(); var sysid = "Test".ToCharArray().Select(a => (byte)a).ToArray(); var appid = "App1".ToCharArray().Select(a => (byte)a).ToArray(); var sc = ServerConfig.Create() .SetSysId(sysid) .SetApplicationData(appid) .BindApplication(Program.App) .SetTimeout(TimeSpan.FromSeconds(10)) .SetLocalIpep(ipep) .SetMaxPlayer(8) ; Server.Start(sc); }
static async Task Main() { var config = new ServerConfig(); config.On <int>().In <Command>().Call <Handler>(); using (var app = config.Create("127.0.0.1", 4000)) { await app.Run(); } }
static void Main(string[] args) { using (var config = new ServerConfig(1)) { config.When <int>() .From <MyCommand>() .Call <MyHandler>(); config.Channel <MyChannel>() .When <int>() .From <MyCommand>() .Call <MyHandler>(); using (var channel = config.Channel <MyChannel>()) { channel.When <int>() .From <MyCommand>() .Call <MyHandler>(); channel.When <int>() .From <MyCommand>() .Call <MyHandler>(); using (var inner = channel.Channel <MyChannel>()) { inner.When <int>() .From <MyCommand>() .Call <MyHandler>(); inner.When <int>() .From <MyCommand>() .Call <MyHandler>(); } using (var when = channel.When <int>()) { when.From <MyCommand>() .Call <MyHandler>(); when.From <MyCommand>() .Call <MyHandler>(); } } using (var server = config.Create()) { // server.Listen("127.0.0.1", 4000); } } }
public override SocketTasks StartServer() { ServerConfig config; if (!string.IsNullOrWhiteSpace(m_RsaXmlPath)) { var xml = Resources.Load <TextAsset>(m_RsaXmlPath); config = ServerConfig.FromXML(xml.text, m_Port); } else { config = ServerConfig.Create(m_Port); } m_Server = Connection.StartServer(config); Setup(m_Server); return(SocketTask.Done.AsTasks()); }
public static void StartServer1(IPEndPoint ipep) { Server = new UdpServerLite(); App = new TestApplication(); var sysid = "Test".ToCharArray().Select(a => (byte)a).ToArray(); var appid = "App1".ToCharArray().Select(a => (byte)a).ToArray(); var sc = ServerConfig.Create() .SetSysId(sysid) .SetApplicationData(appid) .BindApplication(Program.App) .SetTimeout(TimeSpan.FromSeconds(10)) //.SetFiberPool(new Utilities.FiberPool(8)) .SetLocalIpep(ipep) .SetMaxPlayer(8) ; Server.Start(sc); }