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