public override void Init() { client = new PESocket <ClientSession, GameMessage>(); client.StartAsClient(ServiceConfigure.srvIP, ServiceConfigure.serPot); client.SetLog(true, (string msg, int lv) => { switch (lv) { case 0: msg = "Log:" + msg; Debug.Log(msg); break; case 1: msg = "Warn:" + msg; Debug.LogWarning(msg); break; case 2: msg = "Error:" + msg; Debug.LogError(msg); break; case 3: msg = "Info:" + msg; Debug.Log(msg); break; } }); }
private void Start() { //在客户端新建一个Socket client = new PESocket <ClientSession, NetMessage>(); //配置Ip和端口 client.StartAsClient(IPConfigure.srvIP, IPConfigure.srePort); //设置打印日志的接口 client.SetLog(true, (string message, int level) => { message = "Log:" + message; switch (level) { case 0: Debug.Log(message); break; case 1: Debug.LogWarning(message); break; case 2: Debug.LogError(message); break; case 3: Debug.Log(message); break; default: break; } }); }
public void InitSvc() { client = new PESocket <ClientSession, GameMsg>(); client.SetLog(true, (string msg, int lv) => { switch (lv) { case 0: msg = "Log:" + msg; Debug.Log(msg); break; case 1: msg = "LogWarning:" + msg; Debug.LogWarning(msg); break; case 2: msg = "LogError:" + msg; Debug.LogError(msg); break; case 4: msg = "Info:" + msg; Debug.Log(msg); break; } }); client.StartAsClient(SrvCfg.srvIP, SrvCfg.srvPort); PECommon.Log("Init NetSvc..."); }
private void Start() { client = new PESocket <ClientSession, NetMsg>(); client.StartAsClient(IPCfg.srvIP, IPCfg.srvPort); client.SetLog(true, (string msg, int lv) => { switch (lv) { case 0: msg = "Log:" + msg; Debug.Log(msg); break; case 1: msg = "LogWarning:" + msg; Debug.LogWarning(msg); break; case 2: msg = "LogError:" + msg; Debug.LogError(msg); break; case 4: msg = "Info:" + msg; Debug.Log(msg); break; } }); }
private void Start() { socket = new PESocket <ClientSession, NetMsg>(); socket.StartAsClient(ServerCfg.IP, ServerCfg.Port); SetLog(); }
public void InitNetService() { instance = this; client = new PESocket <ClientSession, GameMsg>(); client.StartAsClient(ServerConfig.serverIP, ServerConfig.serverPort); client.SetLog(true, (string msg, int lv) => { switch (lv) { case 0: msg = "Log:" + msg; Debug.Log(msg); break; case 1: msg = "Warn:" + msg; Debug.LogWarning(msg); break; case 2: msg = "Error:" + msg; Debug.LogError(msg); break; case 3: msg = "Info:" + msg; Debug.Log(msg); break; } }); PECommon.Log("NetService Init..."); }
public override void InitSev() { NetMonoSev.InitSingleton().Init(); client = new PESocket <ClientSession, GameMsg>(); client.StartAsClient(SerCfg.serIP, SerCfg.serProt); client.SetLog(true, (msg, lv) => { switch (lv) { case 0: msg = "Log: " + msg; Debug.Log(msg); break; case 1: msg = "Warm: " + msg; Debug.LogWarning(msg); break; case 2: msg = "Error: " + msg; Debug.LogError(msg); break; case 3: msg = "Info: " + msg; Debug.Log(msg); break; } }); Debug.Log("Init NetSev..."); }
public void InitSvc() { Instance = this; client = new PESocket <ClientSession, GameMsg>(); client.SetLog(true, (string msg, int lv) => { switch (lv) { case 0: msg = "Log:" + msg; Debug.Log(msg); break; case 1: msg = "Warn:" + msg; Debug.LogWarning(msg); break; case 2: msg = "Error:" + msg; Debug.LogError(msg); break; case 3: msg = "Info:" + msg; Debug.Log(msg); break; } }); client.StartAsClient(srvIP, srvPort); }
public void InitSvc() { Instance = this; client = new PESocket <ClientSession, GameMsg>(); client.SetLog(true, (string msg, int lv) => { switch (lv) { case 0: msg = "Log:" + msg; Debug.Log(msg); break; case 1: msg = "Warn:" + msg; Debug.LogWarning(msg); break; case 2: msg = "Error:" + msg; Debug.LogError(msg); break; case 3: msg = "Info:" + msg; Debug.Log(msg); break; default: break; } }); //client.StartAsClient(SrvCfg.srvIP, SrvCfg.srvPort); if (isInner) { client.StartAsClient(SrvCfg.localIP, SrvCfg.innerPort); //内网测试 } else { IPHostEntry host = Dns.GetHostEntry(SrvCfg.strDomain); IPAddress ip = host.AddressList[0]; client.StartAsClient(ip.ToString(), SrvCfg.externalPort); //外网测试 } PECommon.Log("Init NetSvc..."); }
public void InitSvc() { Instance = this; client = new PESocket <ClientSession, GameMsg>(); //client.SetLog(true, (string msg, int lv) => //{ // switch (lv) // { // case 0: // break; // case 1: // break; // case 2: // break; // case 3: // break; // } //}); client.StartAsClient(SvcCfg.ServerIP, SvcCfg.ServerPort); PECommon.Log("Init NetSvc..." + SvcCfg.ServerIP + " : " + SvcCfg.ServerPort); }
static void Main(string[] args) { client = new PESocket <ClientSession, NetMsg>(); client.StartAsClient(IPCfg.srvIP, IPCfg.srvPort); Console.WriteLine("\nInput 'quit' to stop client!"); while (true) { string ipt = Console.ReadLine(); if (ipt == "quit") { client.Close(); break; } else { client.session.SendMsg(new NetMsg { text = ipt }); } } }
static void Main(string[] args) { //TestCode //Random rd = new Random(); //byte[] data = new byte[10]; //rd.NextBytes(data); //byte[] compressBytes = PETool.Compress(data); //byte[] deCompress = PETool.DeCompress(compressBytes); //for(int i = 0; i < data.Length; i++) { // if(data[i] != deCompress[i]) { // Console.WriteLine("压缩数据出错。"); // return; // } //} //Console.WriteLine("压缩数据成功。"); client = new PESocket <ClientSession, NetMsg>(); client.StartAsClient(IPCfg.srvIP, IPCfg.srvPort); Console.WriteLine("\nInput 'quit' to stop client!"); while (true) { string ipt = Console.ReadLine(); if (ipt == "quit") { client.Close(); break; } else { client.session.SendMsg(new NetMsg { text = ipt }); } } }
public void InitSvc() { instance = this; client = new PESocket <ClientSession, GameMsg>(); //根据回调的不同等级 client.SetLog(true, (string msg, int lv) => { switch (lv) { case 0: msg = "Log" + msg; Debug.Log(msg); break; case 1: msg = "LogWarning" + msg; Debug.LogWarning(msg); break; case 2: msg = "LogError" + msg; Debug.LogError(msg); break; case 3: msg = "LogInfo" + msg; Debug.Log(msg); break; default: break; } }); client.StartAsClient(ServiceConfig.srvIP, ServiceConfig.srvPort); PECommon.Log("Init NetServece"); }