예제 #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);
            }
        }
예제 #2
0
 static void customServer_NewSessionConnected(CustomSession session)
 {
     Console.WriteLine("{0}: Session {1} is opened.", session.AppServer.Name, session.SessionID);
 }
예제 #3
0
 static void customServer_SessionClosed(CustomSession session, CloseReason reason)
 {
     Console.WriteLine("{0}: Session {1} is closed.", session.AppServer.Name, session.SessionID);
 }
예제 #4
0
 private void AppServer_NewSessionConnected(CustomSession session)
 {
     session.Send("客户端:" + session.SessionID + DateTime.Now + "己上线");
 }
예제 #5
0
 private void AppServer_SessionClosed(CustomSession session, SuperSocket.SocketBase.CloseReason value)
 {
     session.Close();
 }