Пример #1
0
 public static ConvsationManager getInstance()
 {
     if (instance == null)
     {
         lock (locker)
         {
             if (instance == null)
             {
                 instance = new ConvsationManager();
             }
         }
     }
     return(instance);
 }
Пример #2
0
        private string handleCommand(Socket socket, string requestStr, Request request)
        {
            string back = "success";

            switch (request.Code)
            {
            case (int)RequestCode.RunCmd:
                back = runCmd(request.Args[0], request.Args[1]);
                break;

            case (int)RequestCode.FindWindow:
                back = findWindowHwnd(request.Args[0]);
                break;

            case (int)RequestCode.SendWindowInfo:
                back = PasteToWindow((IntPtr)int.Parse(request.Args[0]), request.Args[1]);
                break;

            case (int)RequestCode.RemoteFindWindow:
                var socketClient = getConnectedSocketClient(request.Args[0], request.Args[1]);
                back = socketClient.remoteFindWindow(request.Args[2]).ToString();
                break;

            case (int)RequestCode.ConversationLongLink:
                ConvsationManager.getInstance().addSocket(socket);
                mLogHelper.InfoFormat("addr:{0}, deviceId:{1}, Conversation Link", ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(), request.DeviceId);
                break;

            case (int)RequestCode.ConversationNote:
            case (int)RequestCode.ConversationRingNote:
                int count = ConvsationManager.getInstance().broadcast(socket, requestStr);
                mLogHelper.InfoFormat("addr:{0}, deviceId:{1}, Conversation broadcast:{2}", ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(), request.DeviceId, count);
                back = requestStr;
                break;

            case (int)RequestCode.ConversationDisconnect:
                mLogHelper.InfoFormat("addr:{0}, deviceId:{1}, Conversation unlink", ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(), request.DeviceId);
                ConvsationManager.getInstance().removeSocket(socket);
                break;

            default:
                back = null;
                break;
            }
            return(back);
        }