示例#1
0
        static void AppServer_NewRequestReceived(MyAppSession session, StringRequestInfo requestInfo)
        {
            Console.WriteLine("收到客户端信息: " + requestInfo.Key + " " + requestInfo.Body);
            //session.Send("\r\n msg:" + requestInfo.Body);
            session.Send(requestInfo.Key);

            //switch (requestInfo.Key.ToUpper())
            //{
            //    case ("ECHO"):
            //        session.Send(requestInfo.Body);
            //        break;
            //    case ("ADD"):
            //        int sum = 0;
            //        requestInfo.Parameters.ToList().ForEach(c => sum += Convert.ToInt32(c));
            //        session.Send(sum.ToString());
            //        break;
            //    case ("MULT"):
            //        var result = 1;
            //        foreach (var factor in requestInfo.Parameters.Select(p => Convert.ToInt32(p)))
            //        {
            //            result *= factor;
            //        }
            //        session.Send(result.ToString());
            //        break;
            //}
        }
示例#2
0
 static void AppServer_SessionClosed(MyAppSession session, CloseReason reason)
 {
     Console.WriteLine("一个客户端断开了连接" + (count2++) + ": " + session.RemoteEndPoint);
 }
示例#3
0
 static void AppServer_NewSessionConnected(MyAppSession session)
 {
     //session.Send("已连接上Socket服务器");
     Console.WriteLine("发现一个新的客户端连接" + (count++) + ": " + session.RemoteEndPoint);
 }