Esempio n. 1
0
        public static void SendBrowserJob_ASYNC(TransferElementSession session, LogElementDTO logElement)
        {
            var serverRequest = new TransferElementRequest()
            {
                Type = TransferElementRequestType.BrowserJob, Data = logElement
            };
            var    serverRequestJSON = SerializationHelper.Serialize(serverRequest, SerializationType.Json);
            string error;
            var    serverResponseJSON = PlayerCommunicationClient.SendRequest_Threading(session.ProcessGUID, serverRequestJSON, out error, async: true);

            if (serverResponseJSON == null)
            {
                return;
            }
            TransferElementResponse serverResponse = null;

            if (error == null)
            {
                serverResponse = SerializationHelper.Deserialize <TransferElementResponse>(serverResponseJSON, SerializationType.Json);
            }

            if (error != null || !serverResponse.Success)
            {
                throw new Exception($"Error occured while sending starting browser job ({error ?? serverResponse.Message})");
            }
        }
Esempio n. 2
0
        public static void SendSyncSession(Guid serverGUID, Guid sessionGUID, int processId) //Process.GetCurrentProcess().Id
        {
            var data = new TransferElementSession()
            {
                ProcessGUID = sessionGUID, ProcessId = processId
            };

            var serverRequest = new TransferElementRequest()
            {
                Type = TransferElementRequestType.SyncSession, Data = data
            };
            var    serverRequestJSON = SerializationHelper.Serialize(serverRequest, SerializationType.Json);
            string error;
            var    serverResponseJSON = PlayerCommunicationClient.SendRequest_Threading(serverGUID, serverRequestJSON, out error);
            TransferElementResponse serverResponse = null;

            if (error == null)
            {
                serverResponse = SerializationHelper.Deserialize <TransferElementResponse>(serverResponseJSON, SerializationType.Json);
            }

            if (error != null || !serverResponse.Success)
            {
                throw new Exception($"Error occured while communicating with player ({error ?? serverResponse.Message})");
            }
        }
Esempio n. 3
0
        public static bool SendClosingSession(Guid serverGUID, Guid processGUID, int processId)
        {
            var session = new TransferElementSession()
            {
                ProcessGUID = processGUID, ProcessId = processId
            };
            var serverRequest = new TransferElementRequest()
            {
                Type = TransferElementRequestType.ClosingSession, Data = session
            };
            var    serverRequestJSON = SerializationHelper.Serialize(serverRequest, SerializationType.Json);
            string error;
            var    serverResponseJSON = PlayerCommunicationClient.SendRequest_Threading(serverGUID, serverRequestJSON, out error);

            if (!String.IsNullOrWhiteSpace(error))
            {
                throw new Exception(error);
            }

            var serverResponse = SerializationHelper.Deserialize <TransferElementResponse>(serverResponseJSON, SerializationType.Json);

            return(!serverResponse.Success);
        }