Exemple #1
0
 private async Task Send(RPCMethodId id, object obj)
 {
     if (client != null)
     {
         byte[] bytes = RPCTypes.Serialize(id, obj);
         await client.GetStream().WriteAsync(bytes, 0, bytes.Length);
     }
 }
Exemple #2
0
        internal void OnRequestReceived(RPCMethodId methodId, object arg)
        {
            switch (methodId)
            {
            case RPCMethodId.OnUIData:
                userClient.OnUIData((UIData)arg);
                break;

            case RPCMethodId.OnConsoleUpdate:
                userClient.OnConsoleUpdate((ConsoleUpdate)arg);
                break;

            case RPCMethodId.OnEncodeState:
                userClient.OnEncodeState((EncodeState)arg);
                break;

            case RPCMethodId.OnLogFile:
                userClient.OnLogFile((string)arg);
                break;

            case RPCMethodId.OnCommonData:
                userClient.OnCommonData((CommonData)arg);
                break;

            case RPCMethodId.OnProfile:
                userClient.OnProfile((ProfileUpdate)arg);
                break;

            case RPCMethodId.OnAutoSelect:
                userClient.OnAutoSelect((AutoSelectUpdate)arg);
                break;

            case RPCMethodId.OnServiceSetting:
                userClient.OnServiceSetting((ServiceSettingUpdate)arg);
                break;

            case RPCMethodId.OnLogoData:
                userClient.OnLogoData((LogoData)arg);
                break;

            case RPCMethodId.OnDrcsData:
                userClient.OnDrcsData((DrcsImageUpdate)arg);
                break;

            case RPCMethodId.OnAddResult:
                userClient.OnAddResult((string)arg);
                break;

            case RPCMethodId.OnOperationResult:
                userClient.OnOperationResult((OperationResult)arg);
                break;
            }
        }
Exemple #3
0
        internal void OnRequestReceived(RPCMethodId methodId, object arg)
        {
            switch (methodId)
            {
            case RPCMethodId.OnAddResult:
                userClient.OnAddResult((string)arg);
                break;

            case RPCMethodId.OnOperationResult:
                userClient.OnOperationResult((OperationResult)arg);
                break;
            }
        }
        private void OnRequestReceived(RPCMethodId methodId, object arg)
        {
            switch (methodId)
            {
            case RPCMethodId.OnSetting:
                userClient.OnSetting((Setting)arg);
                break;

            case RPCMethodId.OnQueueData:
                userClient.OnQueueData((QueueData)arg);
                break;

            case RPCMethodId.OnQueueUpdate:
                userClient.OnQueueUpdate((QueueUpdate)arg);
                break;

            case RPCMethodId.OnLogData:
                userClient.OnLogData((LogData)arg);
                break;

            case RPCMethodId.OnLogUpdate:
                userClient.OnLogUpdate((LogItem)arg);
                break;

            case RPCMethodId.OnConsole:
                userClient.OnConsole((ConsoleData)arg);
                break;

            case RPCMethodId.OnConsoleUpdate:
                userClient.OnConsoleUpdate((ConsoleUpdate)arg);
                break;

            case RPCMethodId.OnLogFile:
                userClient.OnLogFile((string)arg);
                break;

            case RPCMethodId.OnState:
                userClient.OnState((State)arg);
                break;

            case RPCMethodId.OnFreeSpace:
                userClient.OnFreeSpace((DiskFreeSpace)arg);
                break;

            case RPCMethodId.OnOperationResult:
                userClient.OnOperationResult((string)arg);
                break;
            }
        }
Exemple #5
0
        internal void OnRequestReceived(Client client, RPCMethodId methodId, object arg)
        {
            switch (methodId)
            {
            case RPCMethodId.SetSetting:
                server.SetSetting((Setting)arg);
                break;

            case RPCMethodId.AddQueue:
                server.AddQueue((AddQueueDirectory)arg);
                break;

            case RPCMethodId.RemoveQueue:
                server.RemoveQueue((string)arg);
                break;

            case RPCMethodId.PauseEncode:
                server.PauseEncode((bool)arg);
                break;

            case RPCMethodId.RequestSetting:
                server.RequestSetting();
                break;

            case RPCMethodId.RequestQueue:
                server.RequestQueue();
                break;

            case RPCMethodId.RequestLog:
                server.RequestLog();
                break;

            case RPCMethodId.RequestConsole:
                server.RequestConsole();
                break;

            case RPCMethodId.RequestLogFile:
                server.RequestLogFile((LogItem)arg);
                break;

            case RPCMethodId.RequestState:
                server.RequestState();
                break;

            case RPCMethodId.RequestFreeSpace:
                server.RequestFreeSpace();
                break;
            }
        }
Exemple #6
0
        static void DoCommand(RPCMethodId id, string[] args)
        {
            var inPipe = new AnonymousPipeClientStream(PipeDirection.In,
                                                       Environment.GetEnvironmentVariable("IN_PIPE_HANDLE"));
            var outPipe = new AnonymousPipeClientStream(PipeDirection.Out,
                                                        Environment.GetEnvironmentVariable("OUT_PIPE_HANDLE"));

            var tag   = (args.Length >= 1) ? args[0] : "";
            var bytes = RPCTypes.Serialize(id, tag);

            outPipe.Write(bytes, 0, bytes.Length);
            var ret = RPCTypes.Deserialize(inPipe).Result;

            Console.WriteLine((string)ret.arg);
        }
Exemple #7
0
 private async Task Send(RPCMethodId id, AddQueueRequest obj)
 {
     if (client != null)
     {
         var data       = new List <byte[]>();
         var ms         = new MemoryStream();
         var serializer = new DataContractSerializer(typeof(AddQueueRequest));
         serializer.WriteObject(ms, obj);
         data.Add(ms.ToArray());
         var    objbyes = RPCData.CombineChunks(data);
         byte[] bytes   = RPCData.Combine(
             BitConverter.GetBytes((short)id),
             BitConverter.GetBytes(objbyes.Length),
             objbyes);
         await client.GetStream().WriteAsync(bytes, 0, bytes.Length);
     }
 }
Exemple #8
0
        public static byte[] Serialize(RPCMethodId id, object obj)
        {
            Type type = ArgumentTypes[id];

            if (type == null)
            {
                return(RPCData.Combine(
                           BitConverter.GetBytes((short)id),
                           BitConverter.GetBytes((int)0)));
            }
            var objbyes = Serialize(type, obj);

            //Debug.Print("Send: " + System.Text.Encoding.UTF8.GetString(objbyes));
            return(RPCData.Combine(
                       BitConverter.GetBytes((short)id),
                       BitConverter.GetBytes(objbyes.Length),
                       objbyes));
        }
        private async Task Send(RPCMethodId id, object obj)
        {
            byte[] bytes = RPCTypes.Serialize(id, obj);
            foreach (var client in ClientList.ToArray())
            {
                try
                {
                    await client.GetStream().WriteAsync(bytes, 0, bytes.Length);

                    client.TotalSendCount++;
                }
                catch (Exception)
                {
                    Util.AddLog("クライアント(" +
                                client.HostName + ":" + client.Port + ")との接続が切れました", null);
                    client.Close();
                    OnClientClosed(client);
                }
            }
        }
Exemple #10
0
        public static byte[] Serialize(RPCMethodId id, object obj)
        {
            Type type = ArgumentTypes[id];

            if (type == null)
            {
                return(Combine(
                           BitConverter.GetBytes((short)id),
                           BitConverter.GetBytes((int)0)));
            }
            var ms         = new MemoryStream();
            var serializer = new DataContractSerializer(type);

            serializer.WriteObject(ms, obj);
            var objbyes = ms.ToArray();

            //Debug.Print("Send: " + System.Text.Encoding.UTF8.GetString(objbyes));
            return(Combine(
                       BitConverter.GetBytes((short)id),
                       BitConverter.GetBytes(objbyes.Length),
                       objbyes));
        }
        internal void OnRequestReceived(Client client, RPCMethodId methodId, object arg)
        {
            switch (methodId)
            {
            case RPCMethodId.SetProfile:
                server.SetProfile((ProfileUpdate)arg);
                break;

            case RPCMethodId.SetAutoSelect:
                server.SetAutoSelect((AutoSelectUpdate)arg);
                break;

            case RPCMethodId.AddQueue:
                server.AddQueue((AddQueueRequest)arg);
                break;

            case RPCMethodId.ChangeItem:
                server.ChangeItem((ChangeItemData)arg);
                break;

            case RPCMethodId.PauseEncode:
                server.PauseEncode((PauseRequest)arg);
                break;

            case RPCMethodId.CancelAddQueue:
                server.CancelAddQueue();
                break;

            case RPCMethodId.CancelSleep:
                server.CancelSleep();
                break;

            case RPCMethodId.SetCommonData:
                server.SetCommonData((CommonData)arg);
                break;

            case RPCMethodId.SetServiceSetting:
                server.SetServiceSetting((ServiceSettingUpdate)arg);
                break;

            case RPCMethodId.AddDrcsMap:
                server.AddDrcsMap((DrcsImage)arg);
                break;

            case RPCMethodId.EndServer:
                server.EndServer();
                break;

            case RPCMethodId.Request:
                server.Request((ServerRequest)arg);
                break;

            case RPCMethodId.RequestLogFile:
                server.RequestLogFile((LogFileRequest)arg);
                break;

            case RPCMethodId.RequestLogoData:
                server.RequestLogoData((string)arg);
                break;

            case RPCMethodId.RequestDrcsImages:
                server.RequestDrcsImages();
                break;
            }
        }