Exemplo n.º 1
0
    private bool SendMessage(MsgInfo msgInfo)
    {
        lock (_lockObject)
        {
            if (_socket == null)
            {
                _sendQueue.Enqueue(msgInfo);
                return(false);
            }

            if (!IsConnected())
            {
                _sendQueue.Enqueue(msgInfo);
                return(false);
            }
            if (_sendQueue.Count > 0)
            {
                _sendQueue.Enqueue(msgInfo);
                return(true);
            }

            _sendQueue.Enqueue(msgInfo);
            return(SendSocket(msgInfo));
        }
    }
Exemplo n.º 2
0
    private bool SendSocket(MsgInfo msgInfo)
    {
        try
        {
            _encodeMs.Seek(0, SeekOrigin.Begin);
            _netEnDecode.Encode(_encodeBw, msgInfo.Cmd, PackId, msgInfo.Data);
            var bytes = _encodeMs.ToArray();

            //if ((ProtoCmdId) msgInfo.Cmd != ProtoCmdId.HeartbeatReq)
            //{
            //    var msg = string.Format("Socket Send Cmd:{0} {1}", (ProtoCmdId)msgInfo.Cmd, msgInfo.Cmd);
            //    _onNetRespEvent(NetMsg.Create(NetMsgType.Debug, msg));
            //}

            _sendEventArgs.SetBuffer(bytes, 0, bytes.Length);
            if (!_socket.SendAsync(_sendEventArgs))
            {
                SendCompleted(_sendEventArgs);
            }
            return(true);
        }
        catch (Exception e)
        {
            Close("SendToAsync Error:" + e.Message + " Cmd:" + msgInfo.Cmd);
            return(false);
        }
    }
Exemplo n.º 3
0
    public bool SendMessage(UInt32 cmd, object data = null)
    {
        //if ((ProtoCmdId) cmd != ProtoCmdId.HeartbeatReq)
        //{
        //    Odin.Log.Info("SendMessage-->cmd:{0} {1} Socket Connected {2}", (ProtoCmdId) cmd, cmd, IsConnected());
        //}

        var msgInfo = new MsgInfo {
            Cmd = cmd, Data = data
        };

        if (_packId == 0)
        {
            //发送连接成功的第一个包
            //如果已断开丢失第一个包
            //重连验证包或登录验证包
            if (!IsConnected())
            {
                _packId++;
                return(false);
            }
            return(SendSocket(msgInfo));
        }
        return(SendMessage(msgInfo));
    }
Exemplo n.º 4
0
Arquivo: MsgKit.cs Projeto: Daoting/dt
        /// <summary>
        /// 向所有副本的所有在线用户广播信息
        /// </summary>
        /// <param name="p_msg"></param>
        public static async Task BroadcastAllOnline(MsgInfo p_msg)
        {
            Throw.IfNull(p_msg);

            var msg = p_msg.GetOnlineMsg();
            int cnt = await Kit.GetSvcReplicaCount();

            if (cnt > 1)
            {
                // 多副本推送
                Kit.RemoteMulticast(new BroadcastEvent {
                    Msg = msg
                });
            }
            else
            {
                // 本地单副本推送
                foreach (var ls in Online.All.Values)
                {
                    foreach (var ci in ls)
                    {
                        ci.AddMsg(msg);
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="buf"></param>
        /// <param name="ofs"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        ///
        public void DispatchMessage(byte[] buf, ushort ofs, ushort len, object state = null)
        {
            if (buf == null)
            {
                throw new ArgumentNullException("buf");
            }
            if (len == 0)              // actually, len should be >= header size...
            {
                throw new ArgumentException("len", "len must be nonzero");
            }

            byte rawOpcode = TransportProtocol.GetMessageOpcode(buf, ofs);

            if (!Enum.IsDefined(typeof(AURAMsgOpcode), rawOpcode))
            {
                throw new InvalidOperationException(string.Format("MessageFactory.DispatchMessage(): opcode 0x{0:x2} unknown", rawOpcode));
            }

            AURAMsgOpcode opcode = (AURAMsgOpcode)rawOpcode;

            MsgInfo msgInfo = null;

            if (!msgHandlerMap_.TryGetValue(opcode, out msgInfo))
            {
                throw new InvalidOperationException(string.Format("MessageFactory.DispatchMessage(): no handler registered for {0}", opcode));
            }

            msgInfo.ReconstituteAndDispatchMessage(buf, ofs, len, state);
        }
Exemplo n.º 6
0
 /******************************************************************************************
 * Function name : txtProgressRate_TextChanged
 * Purpose       : total 하기 (progressRate + final test = total score)
 * Input         : void
 * Output        : void
 ******************************************************************************************/
 #region protected void txtProgressRate_TextChanged(object sender, EventArgs e)
 protected void txtProgressRate_TextChanged(object sender, EventArgs e)
 {
     try
     {
         int xpro   = Convert.ToInt32(this.txtProgressRate.Text == string.Empty ? "0" : this.txtProgressRate.Text);
         int xfinal = Convert.ToInt32(this.txtFinalTest.Text == string.Empty ? "0" : this.txtFinalTest.Text);
         if (xpro + xfinal > 100)
         {
             //A030  : <KO>{0}이(가) {1}보다 큽니다.<
             ScriptHelper.Page_Alert(this.Page, MsgInfo.GetMsg("A030",
                                                               new string[] { this.lblTotalScore.Text, "100" },
                                                               new string[] { this.lblTotalScore.Text, "100" },
                                                               Thread.CurrentThread.CurrentCulture
                                                               ));
         }
         else
         {
             this.txtTotalScore.Text = Convert.ToString(xpro + xfinal);
         }
     }
     catch (Exception ex)
     {
         base.NotifyError(ex);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="account">账号</param>
        /// <param name="password">密码</param>
        /// <returns></returns>
        public string Login(string account, string password)
        {
            MsgInfo msgInfo = new MsgInfo {
                Msg = "登录成功", MsgNo = 0, IsError = false
            };
            List <SystemAccountInfo> list = this.GetListByWhere(1, "Account='" + account + "'");

            if (list == null || list.Count <= 0)
            {
                msgInfo.Msg     = "用户名或密码错误";
                msgInfo.MsgNo   = -1;
                msgInfo.IsError = true;
                return(JsonConvert.SerializeObject(msgInfo));
            }
            if (list[0].Password != Security.DESEncrypt(password))
            {
                msgInfo.Msg     = "用户名或密码错误";
                msgInfo.MsgNo   = -1;
                msgInfo.IsError = true;
                return(JsonConvert.SerializeObject(msgInfo));
            }
            if (!list[0].IsEnable)
            {
                msgInfo.Msg     = "您的账号已被禁用,请联系管理员";
                msgInfo.MsgNo   = -1;
                msgInfo.IsError = true;
                return(JsonConvert.SerializeObject(msgInfo));
            }
            msgInfo.Msg     = JsonConvert.SerializeObject(list[0]);
            msgInfo.IsError = false;
            return(JsonConvert.SerializeObject(msgInfo));
        }
Exemplo n.º 8
0
        private MsgInfo validateMsg(Boolean isHtml)
        {
            String      idsStr = ctx.PostIdList("UserIds");
            List <User> users  = userService.GetByIds(idsStr);

            if (users.Count == 0)
            {
                errors.Add(lang("exNoReceiver"));
                return(null);
            }

            String title = ctx.Post("Title");
            String body  = ctx.Post("MsgBody");

            if (isHtml)
            {
                body = ctx.PostHtml("MsgBody");
            }

            if (strUtil.IsNullOrEmpty(title))
            {
                errors.Add(lang("exRequireTitle"));
            }
            if (strUtil.IsNullOrEmpty(body))
            {
                errors.Add(lang("exRequireContent"));
            }

            MsgInfo msgInfo = new MsgInfo();

            msgInfo.Title = title;
            msgInfo.Body  = body;
            msgInfo.Users = users;
            return(msgInfo);
        }
Exemplo n.º 9
0
        public ActionResult Create(SystemMenuInfo model)
        {
            bool   issuc = false;
            string _funs = Request["Functions"];

            model.Functions = _funs;
            int id = menuMgr.Create(model);

            if (id > 0)
            {
                issuc = true;
            }
            MsgInfo msgInfo = new MsgInfo();

            if (issuc)
            {
                msgInfo.IsError = false;
                msgInfo.Msg     = "操作成功!";
                msgInfo.MsgNo   = (int)ErrorEnum.成功;
            }
            else
            {
                msgInfo.IsError = true;
                msgInfo.Msg     = "操作失败!";
                msgInfo.MsgNo   = (int)ErrorEnum.失败;
            }
            return(Content(JsonConvert.SerializeObject(msgInfo)));
        }
Exemplo n.º 10
0
        public ActionResult Sign(LoginParameter loginPara)
        {
            string  res      = mUserMgr.Login(loginPara.MobileOrEmail, loginPara.Password);
            MsgInfo loginMsg = JsonConvert.DeserializeObject <MsgInfo>(res);

            if (!loginMsg.IsError)
            {
                LoginUsers loginUser   = JsonConvert.DeserializeObject <LoginUsers>(loginMsg.Msg);
                string     strUserData = JsonConvert.SerializeObject(loginUser);

                //保存身份信息
                FormsAuthenticationTicket Ticket = new FormsAuthenticationTicket(1, loginUser.Mobile, DateTime.Now, DateTime.Now.AddHours(12), false, strUserData);
                CookieHelper.Add(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(Ticket), RootDomain);//加密身份信息,保存至Cookie
                loginMsg.Msg = loginPara.ReturnUrl;
                if (loginPara.IsRemember)
                {
                    CookieHelper.Add("remember", loginUser.Mobile + "$" + Security.DESEncrypt(loginPara.Password), RootDomain);
                }
                else
                {
                    CookieHelper.Remove("remember");
                }
            }
            return(Json(loginMsg));
        }
Exemplo n.º 11
0
        public ActionResult Modify(SystemRoleInfo model)
        {
            bool           issuc  = false;
            SystemRoleInfo _model = roleMgr.Get(model.Id);

            if (_model != null)
            {
                _model.RoleName = model.RoleName;

                issuc = roleMgr.Update(_model);
            }
            MsgInfo msgInfo = new MsgInfo();

            if (issuc)
            {
                msgInfo.IsError = false;
                msgInfo.Msg     = "操作成功!";
                msgInfo.MsgNo   = (int)ErrorEnum.成功;
            }
            else
            {
                msgInfo.IsError = true;
                msgInfo.Msg     = "操作失败!";
                msgInfo.MsgNo   = (int)ErrorEnum.失败;
            }
            return(Content(JsonConvert.SerializeObject(msgInfo)));
        }
Exemplo n.º 12
0
    private void TaskMsg(MsgInfo msg, GameObject go)
    {
        listTask.Add(go);
        //Debug.Log("listTask.Count == " +listTask.Count) ;
        if (listTask.Count >= 2)
        {
            if (listTask[0] != null)
            {
                SQYAlertViewMoveElement alert1 = listTask[0].GetComponent <SQYAlertViewMoveElement>();
                listTask.RemoveAt(0);
                alert1.closeDes();
                alert1.close();
            }
            else
            {
                listTask.RemoveAt(0);
            }
        }

        //  Debug.Log("go == " + go ) ;
        SQYAlertViewMoveElement alert = go.GetComponent <SQYAlertViewMoveElement>();

        alert.alertViewFreshUI(msg.content, msg.parentObj);


        go.transform.localPosition = new Vector3(0, 100, 0);
    }
Exemplo n.º 13
0
        public override Task <UpdateShowListResult> UpdatePostShowListFun(UpdateMemberPostShowList request, ServerCallContext context)
        {
            UpdateShowListResult ret = new UpdateShowListResult();

            ret.Result = 0;

            try
            {
                UpdatePostShowList rData = new UpdatePostShowList
                {
                    MemberID = request.MemberID
                };

                string sData = JsonConvert.SerializeObject(rData);

                JObject jsMain = new JObject();

                jsMain.Add("CmdID", (int)C2S_CmdID.emUpdatePostShowList);
                jsMain.Add("Data", JsonConvert.DeserializeObject <JObject>(sData));

                MsgInfo info = new MsgInfo(jsMain.ToString(), this.SendToClient);

                this.addQueue?.Invoke(info);

                ret.Result = 1;
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex.Message}");

                SaveLog($"[Error] gRpcImpl::UpdatePostShowListFun, Catch Error, Msg:{ex.Message}");
            }

            return(Task.FromResult(ret));
        }
Exemplo n.º 14
0
        /************************************************************
         * Function name : btnSearch_Click
         * Purpose       : 기간별 개설과정 조회버튼
         * Input         : void
         * Output        : void
         *************************************************************/
        #region protected void btnSearch_Click(object sender, EventArgs e)
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.txtCus_From.Text))
                {
                    ScriptHelper.Page_Alert(this.Page, MsgInfo.GetMsg("A003", new string[] { "조회기간" }, new string[] { "Date From" }, Thread.CurrentThread.CurrentCulture));
                    return;
                }
                else if (string.IsNullOrEmpty(this.txtCus_To.Text))
                {
                    ScriptHelper.Page_Alert(this.Page, MsgInfo.GetMsg("A003", new string[] { "조회기간" }, new string[] { "Date To" }, Thread.CurrentThread.CurrentCulture));
                    return;
                }

                string[] xParams = new string[2];
                xParams[0] = this.txtCus_From.Text;
                xParams[1] = this.txtCus_To.Text;

                this.ddlCus_Date.ClearSelection();

                DataTable xDt = new DataTable();
                xDt = SBROKER.GetTable("CLT.WEB.BIZ.LMS.APPLICATION.vp_m_sms_md",
                                       "GetCourseDate",
                                       LMS_SYSTEM.APPLICATION,
                                       "CLT.WEB.UI.LMS.APPLICATION", (object)xParams, Thread.CurrentThread.CurrentCulture);

                WebControlHelper.SetDropDownList(this.ddlCus_NM, xDt, "course_nm", "course_id");
                //this.ddlCus_NM.Items.FindByValue("11030001").Selected = true;
            }
            catch (Exception ex)
            {
                base.NotifyError(ex);
            }
        }
Exemplo n.º 15
0
        public void Init(int chatID)
        {
            mRoomID = chatID;

            DataTable rowMsgs = DatabaseMgr.GetChatMessages(mRoomID);

            if (rowMsgs != null)
            {
                foreach (DataRow item in rowMsgs.Rows)
                {
                    MsgInfo info = new MsgInfo();
                    string  msg  = item["info"].ToString();
                    info.message    = msg.Substring(0, msg.Length);
                    info.isSignaled = false;
                    info.msgID      = (int)item["recordID"];
                    info.time       = item["time"].ToString();
                    info.user       = item["user"].ToString();
                    info.tick       = 0;
                    mMessages.Add(info);
                }
            }

            int     cntMessages = mMessages.Count;
            DataRow room        = DatabaseMgr.GetChatRoomInfo(mRoomID);

            if (room != null)
            {
                mAccess = room["access"].ToString();
                UpdateUsersFromDB(mRoomID);
                UpdateTasksFromDB(mRoomID);
            }
            return;
        }
Exemplo n.º 16
0
        public ActionResult Create(SystemRoleInfo model)
        {
            bool issuc = false;

            model.CreateDate  = DateTime.Now;
            model.CreateIP    = this.GetIP;
            model.IsCanDelete = true;
            int id = roleMgr.Create(model);

            if (id > 0)
            {
                issuc = true;
            }
            MsgInfo msgInfo = new MsgInfo();

            if (issuc)
            {
                msgInfo.IsError = false;
                msgInfo.Msg     = "操作成功!";
                msgInfo.MsgNo   = (int)ErrorEnum.成功;
            }
            else
            {
                msgInfo.IsError = true;
                msgInfo.Msg     = "操作失败!";
                msgInfo.MsgNo   = (int)ErrorEnum.失败;
            }
            return(Content(JsonConvert.SerializeObject(msgInfo)));
        }
Exemplo n.º 17
0
        /************************************************************
         * Function name : btn_Plus_OnClick
         * Purpose       : SMS 전송 리스트 추가
         * Input         : void
         * Output        : void
         *************************************************************/
        #region protected void btn_Plus_OnClick(object sender, EventArgs e)
        protected void btn_Plus_OnClick(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(this.txtName.Text))
                {
                    ScriptHelper.Page_Alert(this.Page, MsgInfo.GetMsg("A004", new string[] { "이름" }, new string[] { "Name" }, Thread.CurrentThread.CurrentCulture));
                    return;
                }
                else if (string.IsNullOrEmpty(this.txtMobilePhone.Text))
                {
                    ScriptHelper.Page_Alert(this.Page, MsgInfo.GetMsg("A004", new string[] { "휴대폰 번호" }, new string[] { "Mobile Phone" }, Thread.CurrentThread.CurrentCulture));
                    return;
                }

                if (!SentSMSDuplicate(this.lbSentlist, this.txtMobilePhone.Text))
                {
                    this.lbSentlist.Items.Add(new ListItem(this.txtName.Text + " : " + Regex.Replace(this.txtMobilePhone.Text, @"\D", ""), "0"));
                }

                this.lblSendCnt.Text     = TotalCount();
                this.txtName.Text        = "";
                this.txtMobilePhone.Text = "";
            }
            catch (Exception ex)
            {
                base.NotifyError(ex);
            }
        }
Exemplo n.º 18
0
        public ActionResult Delete(FormCollection collection)
        {
            //Message Box Title -- When Error occured, Message Box would be showed.
            string           str_MsgBoxTitle  = MultilingualHelper.GetStringFromResource(languageKey, "AuthorizedHistoryManage_Delete");
            string           str_ID           = collection["ID"];
            string           str_ErrorMsg     = "";
            CommonJsonResult commonJsonResult = new CommonJsonResult();

            commonJsonResult.MsgTitle = str_MsgBoxTitle;

            WCFReturnResult ret             = new WCFReturnResult();
            WebCommonHelper webCommonHelper = new WebCommonHelper();

            webCommonHelper.CallWCFHelper(this, (entity_WCFAuthInfoVM) =>
            {
                ret = authHisMgtHelper.Value.Delete(entity_WCFAuthInfoVM, str_ID);
            });

            if (ret != null && ret.IsSuccess)
            {
                commonJsonResult.ReturnUrl = Url.Action("Index", "AuthorizedHistoryManage", new { Area = "AccessControl" }, Request.Url.Scheme);
                commonJsonResult.Success   = true;

                MsgInfo successMsgInfo = new MsgInfo();
                successMsgInfo.MsgTitle    = str_MsgBoxTitle;
                successMsgInfo.MsgDesc     = MultilingualHelper.GetStringFromResource(languageKey, "I001");
                successMsgInfo.MsgType     = MessageType.Success;
                TempData[ActionMessageKey] = successMsgInfo;
                return(Json(commonJsonResult));
            }
            else
            {
                if (ret.StrList_Error.Count > 0)
                {
                    str_ErrorMsg = string.Join("<br/>", ret.StrList_Error.ToArray());

                    commonJsonResult.ReturnUrl = Url.Action("Index", "AuthorizedHistoryManage", new { Area = "AccessControl" }, Request.Url.Scheme);
                    commonJsonResult.Success   = false;

                    MsgInfo errorMsgInfo = new MsgInfo();
                    errorMsgInfo.MsgTitle      = str_MsgBoxTitle;
                    errorMsgInfo.MsgDesc       = str_ErrorMsg;
                    errorMsgInfo.MsgType       = MessageType.ValidationError;
                    TempData[ActionMessageKey] = errorMsgInfo;
                    return(Json(commonJsonResult));
                }
                else
                {
                    commonJsonResult.ReturnUrl = Url.Action("Index", "AuthorizedHistoryManage", new { Area = "AccessControl" }, Request.Url.Scheme);
                    commonJsonResult.Success   = false;

                    MsgInfo errorMsgInfo = new MsgInfo();
                    errorMsgInfo.MsgTitle      = str_MsgBoxTitle;
                    errorMsgInfo.MsgDesc       = MultilingualHelper.GetStringFromResource(languageKey, "E006");
                    errorMsgInfo.MsgType       = MessageType.ValidationError;
                    TempData[ActionMessageKey] = errorMsgInfo;
                    return(Json(commonJsonResult));
                }
            }
        }
Exemplo n.º 19
0
        public async Task <ResultModel> Run(SendMsgReq req, AppSetting appSetting, HttpContext context)
        {
            if (req == null)
            {
                return(ResultModel.GetNullErrorModel());
            }

            var msg = req.ValidInfo();

            if (msg != string.Empty)
            {
                return(ResultModel.GetParamErrorModel(msg));
            }

            var conn = appSetting.GetMysqlConn(context);

            var param = new MsgInfo()
            {
                Content  = req.Content,
                MsgNo    = Guid.NewGuid().ToString(),
                Sender   = req.Sender,
                Receiver = req.Receiver,
                TypeId   = (int)req.MsgType
            };

            var result = await DapperTools.CreateSelectiveItem(conn, param);

            if (result > 0)
            {
                Logger.Debug($"发送消息成功:{param.MsgNo}");
            }

            return(ResultModel.GetSuccessModel(result));
        }
Exemplo n.º 20
0
        public static string GetHtmlRows(DataSet ds)
        {
            string htmlString = string.Empty;

            if (ds != null)
            {
                if (ds != null && ds.Tables != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    List <MsgInfo> msgList = new List <MsgInfo>();
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        MsgInfo mi = new MsgInfo();
                        mi.ID        = int.Parse(dr["ID"].ToString());
                        mi.RelatedID = int.Parse(dr["RelatedID"].ToString());
                        mi.Question  = dr["Question"].ToString();
                        mi.IsPublic  = dr["IsPublic"].ToString().ToUpper() == "TRUE"?true:false;
                        mi.IsOffline = dr["IsOffline"].ToString().ToUpper() == "TRUE" ? true : false;
                        msgList.Add(mi);
                    }
                    List <VariarionsROW> rows = new List <VariarionsROW>();
                    rows.AddRange(GetMsgRowsByMsgList(msgList));

                    htmlString = JsonSerializer.Serialize(rows);
                }
            }

            return(htmlString);
        }
Exemplo n.º 21
0
        public ActionResult Modify(SystemAccountInfo model)
        {
            bool issuc = false;
            SystemAccountInfo _model = accountMgr.Get(model.Id);

            if (_model != null)
            {
                _model.UserName = model.UserName;
                _model.RoleId   = model.RoleId;
                _model.IsEnable = model.IsEnable;
                _model.Remarks  = model.Remarks;
                if (!string.IsNullOrEmpty(model.Password))
                {
                    _model.Password = Security.DESEncrypt(model.Password);
                }
                issuc = accountMgr.Update(_model);
            }
            MsgInfo msgInfo = new MsgInfo();

            if (issuc)
            {
                msgInfo.IsError = false;
                msgInfo.Msg     = "操作成功!";
                msgInfo.MsgNo   = (int)ErrorEnum.成功;
            }
            else
            {
                msgInfo.IsError = true;
                msgInfo.Msg     = "操作失败!";
                msgInfo.MsgNo   = (int)ErrorEnum.失败;
            }
            return(Content(JsonConvert.SerializeObject(msgInfo)));
        }
Exemplo n.º 22
0
        /// <summary>
        /// Send Message
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SendMsg_Button_Clicked(object sender, EventArgs e)
        {
            var msg = SendMsg.Text;

            if (!string.IsNullOrEmpty(msg))
            {
                MsgInfo msgInfo = new MsgInfo();
                msgInfo.Content   = msg;
                msgInfo.ReceiveId = RemoteUser.Id;
                msgInfo.SendId    = App.CurrentUser.Id;
                var result = await MQTTHelper.Instance.SendMsg(msgInfo);

                client.Message(msgInfo);
                if (result)
                {
                    SendMsg.Text = "";
                    Messages.Add(msgInfo); ScollerToButtom();
                    //Toast_Android.Instance.ShortAlert("Send Successed!");
                }
                else
                {
                    ToastHelper.Instance.ShortAlert("Send Failed!");
                }
            }
        }
Exemplo n.º 23
0
        private void SendPicture(string filename)
        {
            var buf = File.ReadAllBytes(filename);

            if (list.Items.Count == 0)
            {
                AppendNotify("No user online");
                return;
            }

            var msg = new MsgInfo(MsgType.MSG)
            {
                Format  = DataFormat.Image,
                Message = tMessage.Text,
                Data    = buf
            };

            tMessage.Clear();
            if (string.IsNullOrWhiteSpace(tbTarget.Text))
            {
                SendCmd(CMD.ONE2ALL, msg);
            }
            else
            {
                msg.TargetUser = tbTarget.Text;
                SendCmd(CMD.ONE2ONE, msg);
            }

            AppendMsg(msg, true);
        }
Exemplo n.º 24
0
        private void bSend_Click(object sender, EventArgs e)
        {
            if (list.Items.Count == 0)
            {
                MessageBox.Show(this, "No user online.");
                return;
            }

            var msg     = new MsgInfo(MsgType.MSG);
            var content = tMessage.Text;

            tMessage.Clear();

            msg.Message = content;

            if (string.IsNullOrWhiteSpace(tbTarget.Text))
            {
                SendCmd(CMD.ONE2ALL, msg);
            }
            else
            {
                msg.TargetUser = tbTarget.Text;
                SendCmd(CMD.ONE2ONE, msg);
            }

            AppendMsg(msg, true);
        }
Exemplo n.º 25
0
        public ActionResult Destroy(FormCollection col)
        {
            string         id    = col["Id"];
            SystemRoleInfo model = roleMgr.Get(int.Parse(id));

            if (model != null && !model.IsCanDelete)
            {
                return(Content("false"));
            }
            bool res = roleMgr.Delete(new SystemRoleInfo {
                Id = int.Parse(id)
            });
            MsgInfo msgInfo = new MsgInfo();

            if (res)
            {
                msgInfo.IsError = false;
                msgInfo.Msg     = "删除成功!";
                msgInfo.MsgNo   = (int)ErrorEnum.成功;
            }
            else
            {
                msgInfo.IsError = true;
                msgInfo.Msg     = "删除失败!";
                msgInfo.MsgNo   = (int)ErrorEnum.失败;
            }
            return(Content(JsonConvert.SerializeObject(msgInfo)));
        }
Exemplo n.º 26
0
        internal static bool Enqueue(Serial ser, ushort body, MessageType type, ushort hue, ushort font, string lang, string name, string text)
        {
            MsgInfo m = null;

            if (m_Table.ContainsKey(text))
            {
                m = m_Table[text] as MsgInfo;
            }

            if (m == null)
            {
                m_Table[text] = m = new MsgInfo(ser, body, type, hue, font, lang, name);

                m.Count = 0;

                m.Delay = TimeSpan.FromSeconds((((int)(text.Length / 50)) + 1) * 3.5);

                m.NextSend = DateTime.Now + m.Delay;

                return(true);
            }
            else
            {
                m.Count++;

                return(false);
            }
        }
Exemplo n.º 27
0
        public ActionResult Destroys(FormCollection col)
        {
            string Ids = col["Ids"];

            string[]       _Ids  = Ids.Split(',');
            List <string>  ids   = new List <string>();
            SystemRoleInfo model = null;

            foreach (string id in _Ids)
            {
                model = roleMgr.Get(int.Parse(id));
                if (model != null && model.IsCanDelete)
                {
                    ids.Add(model.Id.ToString());
                }
            }

            bool    res     = roleMgr.Deletes(string.Join(",", ids));
            MsgInfo msgInfo = new MsgInfo();

            if (res)
            {
                msgInfo.IsError = false;
                msgInfo.Msg     = "删除成功!";
                msgInfo.MsgNo   = (int)ErrorEnum.成功;
            }
            else
            {
                msgInfo.IsError = true;
                msgInfo.Msg     = "删除失败!";
                msgInfo.MsgNo   = (int)ErrorEnum.失败;
            }
            return(Content(JsonConvert.SerializeObject(msgInfo)));
        }
Exemplo n.º 28
0
        void TimerFunc(object obj)
        {
            if (!start)
            {
                return;
            }
            lock (messageQueue) {
                uint   frame      = frameIndex;
                byte[] framebytes = BitConverter.GetBytes(frame);
                Array.Copy(framebytes, 0, mbytes, 0, framebytes.Length);
                int index = framebytes.Length;
                while (messageQueue.Count > 0)
                {
                    byte[] tempbytes = messageQueue.Dequeue();
                    Array.Copy(tempbytes, 0, mbytes, index, tempbytes.Length);
                    index += tempbytes.Length;
                }

                //发送到各个客户端
                foreach (var item in mConnectDic)
                {
                    IPEndPoint point     = item.Value;
                    byte[]     sendbytes = new byte[index];
                    Array.Copy(mbytes, 0, sendbytes, 0, index);
                    MsgInfo msg = new MsgInfo(point, sendbytes, sendbytes.Length);
                    // 发送两个冗余包,防止丢包
                    GameServer.instance.udp.Send(msg);
                    GameServer.instance.udp.Send(msg);
                    GameServer.instance.udp.Send(msg);
                }

                frameIndex++;
            }
        }
Exemplo n.º 29
0
        /************************************************************
         * Function name : BindHitCnt
         * Purpose       : 공지사항 조회시 조회숫자 Count 메서드
         *
         * Input         : string rSeq (공지사항 번호)
         * Output        : void
         *************************************************************/
        #region public void BindHitCnt(string rSeq)
        public void BindHitCnt(string rSeq)
        {
            try
            {
                //SetNoticeHitCnt
                string xRtn       = Boolean.FalseString;
                string xScriptMsg = string.Empty;

                xRtn = SBROKER.GetString("CLT.WEB.BIZ.LMS.COMMUNITY.vp_y_community_notice_md",
                                         "SetNoticeHitCnt",
                                         LMS_SYSTEM.COMMUNITY,
                                         "CLT.WEB.UI.LMS.COMMUNITY.edu_notice_detail",
                                         (object)rSeq);

                if (xRtn == Boolean.FalseString)
                {
                    //xScriptMsg = "<script>alert('정상적으로 처리되지 않았으니, 관리자에게 문의 바랍니다.');</script>";
                    ScriptHelper.Page_Alert(this.Page, MsgInfo.GetMsg("A103", new string[] { "" }, new string[] { "" }, Thread.CurrentThread.CurrentCulture));
                }
            }
            catch (Exception ex)
            {
                bool rethrow = ExceptionPolicy.HandleException(ex, "Propagate Policy");
                if (rethrow)
                {
                    throw;
                }
            }
        }
Exemplo n.º 30
0
    public void CreateAndMove(MsgInfo msg)
    {
        Object obj = PrefabLoader.loadFromPack("SQY/pbSQYAlertViewMove");


        if (obj != null)
        {
            GameObject go = Instantiate(obj) as GameObject;
            index++;
            go.name = "test_" + index.ToString();

            //  Debug.Log("msg.type == " + msg.type  ) ;


            go.transform.localPosition = Vector3.zero;
            if (msg.type == 0)
            {
                CommonMsg(msg, go);
                list_msgs.Remove(msg);
            }
            else
            {
                //  Debug.Log("TaskMsg");
                TaskMsg(msg, go);
                list_msgTask.Remove(msg);
            }
        }
    }
Exemplo n.º 31
0
        public static bool Enqueue( Serial ser, ushort body, MessageType type, ushort hue, ushort font, string lang, string name, string text )
        {
            MsgInfo m = m_Table[text] as MsgInfo;
            if ( m == null )
            {
                m_Table[text] = m = new MsgInfo( ser, body, type, hue, font, lang, name );

                m.Count = 0;

                m.Delay = TimeSpan.FromSeconds( (((int)(text.Length / 50))+1) * 3.5 );

                m.NextSend = DateTime.Now + m.Delay;

                return true;
            }
            else
            {
                m.Count++;

                return false;
            }
        }
Exemplo n.º 32
0
        private MsgInfo validateMsg( Boolean isHtml )
        {
            String idsStr = ctx.PostIdList( "UserIds" );
            List<User> users = userService.GetByIds( idsStr );
            if (users.Count == 0) {
                errors.Add( lang( "exNoReceiver" ) );
                return null;
            }

            String title = ctx.Post( "Title" );
            String body = ctx.Post( "MsgBody" );
            if (isHtml) body = ctx.PostHtml( "MsgBody" );

            if (strUtil.IsNullOrEmpty( title )) errors.Add( lang( "exRequireTitle" ) );
            if (strUtil.IsNullOrEmpty( body )) errors.Add( lang( "exRequireContent" ) );

            MsgInfo msgInfo = new MsgInfo();
            msgInfo.Title = title;
            msgInfo.Body = body;
            msgInfo.Users = users;
            return msgInfo;
        }
Exemplo n.º 33
0
        public void SendMessage(Message message)
        {
            long id;
            lock (this)
            {
                if (closed)
                {
                    message.Discard();
                    return;
                }
                id = next_out++;
                outgoing[id] = new MsgInfo { Message = message, Seq = new WorkQueue() };
                packet.SendPacket("HEADER", id, JSON.Stringify(message.Header));
            }

            message.Consume(
                (data, offset, len) =>
                {
                    lock (this)
                        packet.SendPacket("DATA", id, data, offset, len);
                },
                (error) =>
                {
                    lock(this) {
                        packet.SendPacket(error == null ? "EOF" : "TXERR", id, error ?? "");
                        if (!closed) outgoing.Remove(id);
                    }
                }
            );
        }
Exemplo n.º 34
0
        void packet_OnPacket(string tag, long msgno, byte[] data, int offset, int len)
        {
            if (closed) return;
            MsgInfo message;
            JObject hdr;

            if (tag == "HEADER")
            {
                if (msgno != next_in)
                {
                    packet.Close("Out of sequence message received");
                    return;
                }
                next_in++;

                try
                {
                    hdr = JSON.Parse(Encoding.UTF8.GetString(data, offset, len)).AsObject();
                }
                catch (JSONException je)
                {
                    packet.Close("Malformed JSON in received header: " + je.Message);
                    return;
                }

                message = incoming[msgno] = new MsgInfo { Message = new Message(hdr), Seq = new WorkQueue() };
                message.Seq.Enqueue(() =>
                {
                    MessageEventHandler handler = OnMessage;
                    if (handler != null) handler(message.Message);
                    if (!message.Message.Consumed)
                        throw new InvalidOperationException("Recieved message was not handled");
                    message.Message.BeginStream((newack, oldack) =>
                    {
                        if (newack == oldack) return;
                        lock (this)
                            packet.SendPacket("ACK", msgno, newack.ToString());
                    }, false);
                });
            }
            else if (tag == "DATA")
            {
                if (!incoming.TryGetValue(msgno, out message))
                {
                    packet.Close("Received DATA with no active message");
                    return;
                }

                message.Seq.Enqueue(() =>
                {
                    if (!message.Closed)
                        message.Message.AddData(data, offset, len);
                });
            }
            else if (tag == "EOF")
            {
                if (!incoming.TryGetValue(msgno, out message))
                {
                    packet.Close("Received EOF with no active message");
                    return;
                }
                if (len > 0)
                {
                    packet.Close("EOF packet must be empty");
                    return;
                }
                message.Seq.Enqueue(() =>
                {
                    if (!message.Closed)
                    {
                        message.Message.End(null);
                        message.Closed = true;
                    }
                });
                incoming.Remove(msgno);
            }
            else if (tag == "TXERR")
            {
                if (!incoming.TryGetValue(msgno, out message))
                {
                    packet.Close("Received EOF with no active message");
                    return;
                }

                message.Seq.Enqueue(() =>
                {
                    if (!message.Closed)
                        message.Message.End(Encoding.UTF8.GetString(data, offset, len));
                    message.Closed = true;
                });
                incoming.Remove(msgno);
            }
            else if (tag == "ACK")
            {
                if (!outgoing.TryGetValue(msgno, out message))
                    return; // not an error, we may have finished sending

                string strbody = Encoding.ASCII.GetString(data, offset, len);
                long ackVal;
                if (!long.TryParse(strbody, out ackVal) || ackVal < 0 || ackVal.ToString() != strbody)
                {
                    packet.Close("Malformed ACK body");
                    return;
                }

                message.Seq.Enqueue(() =>
                {
                    if (ackVal <= message.Message.Acknowledged)
                    {
                        packet.Close("Attempt to move ACK pointer back");
                        return;
                    }
                    if (ackVal > message.Message.TotalSent)
                    {
                        packet.Close("Attempt to move ACK pointer past end of received data");
                        return;
                    }

                    message.Message.Ack(ackVal - message.Message.Acknowledged);
                });
            }
            else
            {
                packet.Close("Unexpected packet of type " + tag);
            }
        }