コード例 #1
0
        public void Connect()
        {
            try
            {
                socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                AbsCoding.Ins = new PbCoding();

                socket.Connect(V_IP, V_Port);

                socket.BeginReceive(readBuffer, 0, 1024, SocketFlags.None, ReceiveCallBack, null);

                TransModel model = new TransModel();
                if (!string.IsNullOrEmpty(V_ConnectKey))
                {
                    model.SetMsg(Convert.ToBase64String(Encoding.UTF8.GetBytes(V_ConnectKey)));
                }
                ins.Send(model);

                //EventMgr.Ins.InvokeDeList(EM_LoginEvent.ConnectSuccess);
            }
            catch (Exception ex)
            {
                //EventMgr.Ins.InvokeDeList(EM_LoginEvent.ConnectFail);
                Debug.Log("无法连接服务器,请重启客户端或联系服务器管理员");
                //AlertMgr.Ins.AddMsg("无法连接服务器,请重启客户端或联系服务器管理员");
            }
        }
コード例 #2
0
        public void Send <T>(int pid, int area, T message)
        {
            TransModel model = new TransModel(pid, area);

            model.SetMsg(message);
            Send(model);
        }