Ejemplo n.º 1
0
        private void AppServer_NewMessageReceived(CustomSession session, string value)
        {
            //单条推送
            // session.Send(DateTime.Now.ToLocalTime()+" 客户端" +session.SessionID +":"+ value);

            //根据条件推送
            //var sessions = appServer.GetSessions(s => s.CompanyId == companyId);
            //foreach (var s in sessions)
            //{
            //    s.Send(data, 0, data.Length);
            //}

            //推送消息给所有客户端
            foreach (var s in appServer.GetAllSessions())
            {
                s.Send(value);
            }
        }
Ejemplo n.º 2
0
 static void customServer_NewSessionConnected(CustomSession session)
 {
     Console.WriteLine("{0}: Session {1} is opened.", session.AppServer.Name, session.SessionID);
 }
Ejemplo n.º 3
0
 static void customServer_SessionClosed(CustomSession session, CloseReason reason)
 {
     Console.WriteLine("{0}: Session {1} is closed.", session.AppServer.Name, session.SessionID);
 }
Ejemplo n.º 4
0
 private void AppServer_NewSessionConnected(CustomSession session)
 {
     session.Send("客户端:" + session.SessionID + DateTime.Now + "己上线");
 }
Ejemplo n.º 5
0
 private void AppServer_SessionClosed(CustomSession session, SuperSocket.SocketBase.CloseReason value)
 {
     session.Close();
 }