void Start() { this.m_Core = new CoreClientNet(); m_Core.Attach(proxy, stub); m_Core.server_join_handler = (ZNet.ConnectionInfo info) => { this.received_texts.Add(string.Format("JoinOK [{0}:{1}] - move[{2}]", info.addr.m_ip, info.addr.m_port, info.moved)); this.currentScrollPos.y = float.PositiveInfinity; }; m_Core.server_leave_handler = (ZNet.ConnectionInfo info) => { this.received_texts.Add(string.Format("Leave [{0}:{1}] - move[{2}]", info.addr.m_ip, info.addr.m_port, info.moved)); this.currentScrollPos.y = float.PositiveInfinity; }; m_Core.server_connect_result_handler = (bool isConnectSuccess) => { if (isConnectSuccess) { this.received_texts.Add("Connected!"); this.currentScrollPos.y = float.PositiveInfinity; } else { this.received_texts.Add("Connect Fail!"); this.currentScrollPos.y = float.PositiveInfinity; } }; m_Core.message_handler = (ZNet.ResultInfo result) => { string str_msg = "Msg : "; str_msg += result.msg; this.received_texts.Add(str_msg); this.currentScrollPos.y = float.PositiveInfinity; }; stub.reponse_Echo = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, RemoteClass.CUserClass testClass, Dictionary<int, int> dic_test, string msg) => { this.received_texts.Add(msg); this.currentScrollPos.y = float.PositiveInfinity; return true; }; this.received_texts.Add("Unity Echo Client Sample."); this.currentScrollPos.y = float.PositiveInfinity; m_Core.Connect( "127.0.0.1", 20000/*tcp port*/, 0,/*protocol version*/ 51/*udp disable=0*/, false/*mobile*/, false/*RecoveryUse*/ ); }
void Start() { this.m_Core = new CoreClientNet(); m_Core.Attach(proxy, stub); m_Core.server_join_handler = (ZNet.ConnectionInfo info) => { this.received_texts.Add(string.Format("JoinOK [{0}:{1}] - move[{2}]", info.addr.m_ip, info.addr.m_port, info.moved)); this.currentScrollPos.y = float.PositiveInfinity; }; m_Core.server_leave_handler = (ZNet.ConnectionInfo info) => { this.received_texts.Add(string.Format("Leave [{0}:{1}] - move[{2}]", info.addr.m_ip, info.addr.m_port, info.moved)); this.currentScrollPos.y = float.PositiveInfinity; }; m_Core.server_connect_result_handler = (bool isConnectSuccess) => { if (isConnectSuccess) { this.received_texts.Add("Connected!"); this.currentScrollPos.y = float.PositiveInfinity; } else { this.received_texts.Add("Connect Fail!"); this.currentScrollPos.y = float.PositiveInfinity; } }; m_Core.message_handler = (ZNet.ResultInfo result) => { string str_msg = "Msg : "; str_msg += result.msg; this.received_texts.Add(str_msg); this.currentScrollPos.y = float.PositiveInfinity; }; stub.reponse_Echo = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, RemoteClass.CUserClass testClass, Dictionary <int, int> dic_test, string msg) => { this.received_texts.Add(msg); this.currentScrollPos.y = float.PositiveInfinity; return(true); }; this.received_texts.Add("Unity Echo Client Sample."); this.currentScrollPos.y = float.PositiveInfinity; m_Core.Connect( "127.0.0.1", 20000 /*tcp port*/, 0,/*protocol version*/ 0 /*udp disable=0*/, true /*mobile*/, false/*RecoveryUse*/ ); }
void Start() { this.m_Core = new CoreClientNet(); m_Core.Attach(proxy, stub); // 서버가 보낸 로그인인증 결과패킷을 처리합니다 stub.reponse_Login = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, bool bResult) => { printf("로그인 인증 결과" + bResult); return(true); }; // 서버로부터 받은 메세지 stub.Chat = (ZNet.RemoteID remote, ZNet.CPackOption pkOption, string txt) => { printf(txt); return(true); }; // 서버이동 시도에 대한 실패 이벤트 m_Core.move_fail_handler = () => { printf("서버이동 처리가 실패하였습니다."); }; // 서버에 입장된 시점 m_Core.server_join_handler = (ZNet.ConnectionInfo info) => { if (info.moved) { // 서버이동이 성공한 시점 : 위치를 목표했던 서버로 설정 server_now = server_tag; printf("서버이동성공 [{0}:{1}] {2}", info.addr.m_ip, info.addr.m_port, server_now); } else { // 최초 입장의 성공시점 : 위치를 로그인 서버로 설정 server_now = UnityCommon.Server.Login; printf("서버입장성공 {0}", server_now); // 최초 로그인 DB인증 시도 요청 proxy.request_Login(ZNet.RemoteID.Remote_Server, ZNet.CPackOption.Basic, "철수", "abcd"); } }; // 서버에 퇴장된 시점 m_Core.server_leave_handler = (ZNet.ConnectionInfo info) => { if (info.moved) { printf("서버이동을 위해 퇴장, 이동할서버 [{0}:{1}]", info.addr.m_ip, info.addr.m_port); } else { printf("서버퇴장성공"); } // 어떤 서버에서 퇴장하든 재접속시 최초접속과 구분하기 위하여 로그인 서버로 세팅해둡니다 server_now = UnityCommon.Server.Login; }; // 서버에 연결된 시점 m_Core.server_connect_result_handler = (bool isConnectSuccess) => { if (isConnectSuccess) { printf("Connected!"); } else { printf("Connect Fail!"); } }; m_Core.message_handler = (ZNet.ResultInfo result) => { string str_msg = "Msg : "; str_msg += result.msg; printf(str_msg); }; printf("프로그램 시작"); // 최초 로그인 시도 m_Core.Connect( "127.0.0.1", 20000 /*tcp port*/, 0,/*protocol version*/ 0 /*udp disable=0*/, true /*mobile*/, false/*RecoveryUse*/ ); }