Exemplo n.º 1
0
        public IAsyncResult BeginProcessRequest(HttpContext context, AsyncCallback cb, object extraData)
        {
            string localUser = WebUtils.GetCookieUser();  //当前登录用户
            string userName=context.Request["username"];   //发送用户

            warpIAsyncResult warp = new warpIAsyncResult(context, cb, extraData, localUser);
            string msg = context.Request["msg"];
            SigleMessage.Instance.SendMessage(msg, warp,userName);
            return warp;
        }
Exemplo n.º 2
0
 public void SendMessage(string msg, warpIAsyncResult warp,string userName)
 {
     if (msg == "connectserver!@#")  //添加客户端到服务端
     {
         clients.Add(warp);
     }
     else  //否则循环客户端,发送数据
     {
         foreach (var item in clients)
         {
         //    if (item.userName ==userName) //判断用户名相同
          //   {
                 item.Send(string.Format("{0:yyyy-MM-dd HH:mm:ss}<br/>{1}", DateTime.Now, msg));
         //    }
         }
         clients.Clear();
     }
 }