Пример #1
0
        public static void RadarAnswer(Socket sockeClient, string msg, Dictionary <string, Session> sessionPool, string sendIP)
        {
            string receiveIP     = string.Empty;
            string receiveMobile = string.Empty;
            string errMsg        = string.Empty;
            //解析消息对象
            SocketDataModel <RadarSendObject, MemberReceiveObject, RadarAnswerObj> socketDataModel = Utils.DataContractJsonDeserializer <SocketDataModel <RadarSendObject, MemberReceiveObject, RadarAnswerObj> >(msg);
            RadarSendObject     sendObj        = socketDataModel.SendObject;
            MemberReceiveObject receiveObj     = socketDataModel.ReceiveObject;
            RadarAnswerObj      radarAnswerObj = socketDataModel.Data;

            //接受信息方是否存在
            if (!GetIP(sessionPool, receiveObj.Mobile, out receiveIP))
            {
                //tb.show(socketDataModel.MessageType, sendObj.StoreId, sendObj.Token, receiveObj.StoreId, receiveObj.Mobile, socketDataModel.Data.ToString(), "0");
                return;
            }

            TcpHelper tb = new TcpHelper();

            //发送消息给接受方
            //var msgObj = Utils.DeserializeObject(socketDataModel.Data.ToString());
            SendData(radarAnswerObj, sessionPool, receiveIP);

            //tb.show(socketDataModel.MessageType, sendObj.StoreId, sendMobile, "", receiveObj.Mobile, socketDataModel.Data.ToString(), "1");
        }
Пример #2
0
        private void radarNotify(HttpContext context)
        {
            string errMsg  = string.Empty;
            string token   = context.Request["token"];
            string action  = context.Request["action"];
            string result  = context.Request["result"];
            string orderid = context.Request["orderid"];
            string sn      = context.Request["sn"];
            string signkey = context.Request["signkey"];

            ClientService service = new ClientService();

            service.Connection();
            RadarNotifyRequestModel dataModel = new RadarNotifyRequestModel();

            dataModel.Token   = token;
            dataModel.SN      = sn;
            dataModel.Result  = result;
            dataModel.OrderId = orderid;
            dataModel.SignKey = "";
            dataModel.Action  = "1";
            dataModel.Coins   = "5";
            byte[] data = DataFactory.CreateRequesProtocolData(TransmiteEnum.雷达通知指令, dataModel);
            service.Send(data);

            RadarSendObject sendObj = new RadarSendObject("100010", "0001");
            //手机号码构建TCP接受对象
            MemberReceiveObject receiveObj     = new MemberReceiveObject("15618920033");
            RadarAnswerObj      radarAnswerObj = new RadarAnswerObj("1", ((int)(TCPAnswerMessageType.出币)).ToString(), "成功出币5");

            SocketDataModel <RadarSendObject, MemberReceiveObject, RadarAnswerObj> socketDataModel = new SocketDataModel <RadarSendObject, MemberReceiveObject, RadarAnswerObj>("3", "0", sendObj, receiveObj, radarAnswerObj);
            //string str = Utils.DataContractJsonSerializer(socketDataModel);

            var dataObj = new {
                answerMsgType = "1",
                answerOjb     = new {
                    result_code = "1",
                    answerMsg   = "成功出币10个"
                }
            };

            TCPServiceBusiness.Send("15618920033", dataObj);
        }