예제 #1
0
        private void tcpSocketListener_NewClientAccepted(object sender, System.Net.Sockets.Socket client, object state)
        {
            if (this.ServerConfig.SocketMode == SocketMode.Tcp)
            {
                if (this.ServerConfig.ControlMode == ControlMode.Loop ||
                    this.ServerConfig.ControlMode == ControlMode.Self ||
                    this.ServerConfig.ControlMode == ControlMode.Parallel)
                {
                    if (ServerConfig.CheckSameSocketSession)
                    {
                        string[] ipInfo        = client.RemoteEndPoint.ToString().Split(':');
                        IChannel socketSession = ChannelManager.GetChannel(ipInfo[0], CommunicateType.NET);
                        if (socketSession != null)
                        {
                            RemoveTcpSocketSession((ISocketSession)socketSession);
                        }
                    }
                }

                AddTcpSocketSession(client);
            }
            else if (this.ServerConfig.SocketMode == SocketMode.Udp)
            {
                object[]       arr           = (object[])state;
                ISocketSession socketSession = new UdpSocketSession(client, (IPEndPoint)arr[1], null);
                Logger.Info(false, String.Format("远程UDP接收到数据>>{0}:{1}", socketSession.RemoteIP, socketSession.RemotePort));

                IList <IRequestInfo> ris = new List <IRequestInfo>();
                ris.Add(new RequestInfo(socketSession.Key, (byte[])arr[0], socketSession));
                IReceivePackage rp = new ReceivePackage(socketSession.RemoteIP, socketSession.RemotePort, ris);
                socketChannel_SocketReceiveData(socketSession, socketSession, rp);
            }
        }
예제 #2
0
        public bool InsertDataIntoReceivePackage(ReceivePackage robj)
        {
            ReceivePackage fb = new ReceivePackage();

            //fb.AwbNumber = robj.AwbNumber;
            fb.CustomerName  = robj.CustomerName;
            fb.FromLocation  = robj.FromLocation;
            fb.ToAddress     = robj.ToAddress;
            fb.UpdatedStatus = robj.UpdatedStatus;
            bool status = false;

            try
            {
                Context.ReceivePackage.Add(fb);

                Context.SaveChanges();
                status = true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                status = false;
            }
            return(status);
        }
        public bool AddReceivePackage(ReceivePackage robj)
        {
            bool status = false;

            try
            {
                status = rep.InsertDataIntoReceivePackage(robj);
            }
            catch (Exception)
            {
                status = false;
            }
            return(status);
        }
예제 #4
0
        public bool AddReceivePackage(ReceivePackage robj)
        {
            bool status = false;

            try
            {
                ReceivePackage fb = new ReceivePackage();
                fb.AwbNumber     = robj.AwbNumber;
                fb.CustomerName  = robj.CustomerName;
                fb.FromLocation  = robj.FromLocation;
                fb.UpdatedStatus = robj.UpdatedStatus;
                fb.ToAddress     = robj.ToAddress;
                status           = rep.InsertDataIntoReceivePackage(robj);
            }
            catch (Exception)
            {
                status = false;
            }
            return(status);
        }
예제 #5
0
파일: Proposal.cs 프로젝트: code32/FrEee
        public override void Execute()
        {
            var errors = GivePackage.Errors.Concat(ReceivePackage.Errors);

            if (errors.Any())
            {
                Executor.Log.Add(Recipient.CreateLogMessage("We could not execute a trade with the " + Recipient + " because: " + errors.First()));
                Recipient.Log.Add(Executor.CreateLogMessage("We could not execute a trade with the " + Executor + " because: " + errors.First()));
            }
            else
            {
                if (GivePackage != null)
                {
                    GivePackage.Transfer(Recipient);
                }
                if (ReceivePackage != null)
                {
                    ReceivePackage.Transfer(Executor);
                }
            }
        }
예제 #6
0
    private static IEnumerator Send(WWWForm form, EnumHTTPHead head)
    {
        string url = "http://" + ip + ":" + port + "/" + GetHeadString(head);
        WWW    www = new WWW(url, form.data, cookies);

        //Debug.Log("request http url " + url + " cmdID, " + _cmdFormDic[form]);
        yield return(www);

        int cmdID = _cmdFormDic[form];

        _cmdFormDic.Remove(form);
        if (www.error != null)
        {
            Debug.Log("serch fail...");
        }
        else if (www.isDone)
        {
            if (www.bytes.Length == 0)
            {
                HttpEvent evt = new HttpEvent(cmdID.ToString());
                _dispatcher.DispatchEventInstance(evt);
                yield break;
            }
            ByteArray receiveBytes = new ByteArray();
            receiveBytes.WriteBytes(www.bytes);

            ReceivePackage pack = CmdUtil.ParseCmd(receiveBytes);
            if (pack.CmdID == (int)MsgType.ErrorMsg)
            {
                RetErrorMsg errorMsg = ProtoBuf.Serializer.Deserialize <RetErrorMsg>(pack.BodyStream);
                if (errorMsg.RetCode == 0)
                {
                    Debug.Log("response http url success" + url);
                    HttpEvent evt = new HttpEvent(cmdID.ToString());
                    _dispatcher.DispatchEventInstance(evt);
                }
                else
                {
                    if (LoginServerErrorCode.ErrorCodeName == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("用户名最多为4个汉字或8个英文字符");
                    }
                    else if (LoginServerErrorCode.ErrorCodeAuthErr == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("验证码错误,还可以输入" + errorMsg.Params + "次");
                    }
                    else if (LoginServerErrorCode.ErrorCodeDb == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("设置密码错误");
                    }
                    else if (LoginServerErrorCode.ErrorCodePass == errorMsg.RetCode)
                    {
                        if (cmdID == (int)MsgType.CheckOldPassword)
                        {
                            PopManager.ShowSimpleItem("密码错误");
                        }
                        else
                        {
                            PopManager.ShowSimpleItem("账号或密码错误");
                        }
                    }
                    else if (LoginServerErrorCode.ErrorCodeParam == errorMsg.RetCode)
                    {
                        if (cmdID == (int)MsgType.ChangePasswd || cmdID == (int)MsgType.SetPasswd || cmdID == (int)MsgType.CheckOldPassword)
                        {
                            PopManager.ShowSimpleItem("密码复杂度不够");
                        }
                        else if (cmdID == (int)MsgType.AuthCode)
                        {
                            PopManager.ShowSimpleItem("获取验证码过于频繁");
                            HttpEvent evt = new HttpEvent(MsgType.ErrorMsg.ToString());
                            _dispatcher.DispatchEventInstance(evt);
                        }
                        else
                        {
                            PopManager.ShowSimpleItem("参数错误");
                        }
                    }
                    else if (LoginServerErrorCode.ErrorCodeIsBind == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("手机号已被绑定");
                    }
                    else if (LoginServerErrorCode.ErrorCodeMsgErr == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("短信服务器出错");
                    }
                    else if (LoginServerErrorCode.ErrorCodeTelErr == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("手机号错误");
                    }
                    else if (LoginServerErrorCode.ErrorCodeMaxMsg == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("今天短信次数已用完");
                    }
                    else if (LoginServerErrorCode.ErrorCodeMaxErr == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("密码错误已超过最大限制");
                    }
                    else if (LoginServerErrorCode.ErrorCodeExist == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("用户名已存在");
                    }
                    else if (LoginServerErrorCode.ErrorCodeUnBind == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("未绑定手机");
                    }
                    else if (LoginServerErrorCode.ErrorCodeSetAccountTm == errorMsg.RetCode)
                    {
                        ulong leftDays = errorMsg.Params / (24 * 60 * 60);
                        if (leftDays >= 1)
                        {
                            PopManager.ShowSimpleItem("还需 " + (uint)leftDays + "天才可以修改用户名");
                        }
                        else
                        {
                            ulong leftHours = errorMsg.Params / (60 * 60);
                            if (leftHours >= 1)
                            {
                                PopManager.ShowSimpleItem("还需 " + (uint)leftHours + "小时才可以修改用户名");
                            }
                            else
                            {
                                PopManager.ShowSimpleItem("还需 " + (uint)(errorMsg.Params / 60) + "分钟才可以修改用户名");
                            }
                        }
                    }
                    else if (LoginServerErrorCode.ErrorCodeSignReward == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("签到奖励领取失败");
                    }
                    else if (LoginServerErrorCode.ErrorCodeSignIned == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("已签到");
                    }
                    else if (LoginServerErrorCode.ErrorCodeRoom == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("未找到房间");
                    }
                    else if (LoginServerErrorCode.ErrorCodeIsFull == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("目标房间已满");
                    }
                    else if (LoginServerErrorCode.ErrorCodeDb == errorMsg.RetCode)
                    {
                        PopManager.ShowSimpleItem("数据库错误");
                    }

                    Log("http cmd error code:" + errorMsg.RetCode + " para:" + errorMsg.Params);
                }
            }
            else
            {
                Log("response http url success " + url + " CmdID:" + (MsgType)pack.CmdID);
                HttpEvent evt = new HttpEvent(pack.CmdID.ToString(), pack.BodyStream);
                _dispatcher.DispatchEventInstance(evt);
            }
        }
    }