コード例 #1
0
ファイル: Server.cs プロジェクト: himadriHK/vCompute
        private void sendToResultQueue(Payload payload)
        {
            string          toId   = null;
            string          fromId = null;
            string          runId;
            payloadDispatch dispatch = null;

            if (taskPayloadDispatch.ContainsKey(payload.runId))
            {
                dispatch      = taskPayloadDispatch[payload.runId];
                toId          = dispatch.fromClient;
                fromId        = dispatch.toClient;
                payload.runId = payload.runId.Replace(dispatch.fromClient, "");
            }

            if (toId != null)
            {
                var requestQueue = taskPayLoad[toId];
                requestQueue.Enqueue(payload);
                if (payload.remainingPayloads == 0 && payload.isAppend == false)
                {
                    ResultEventArgs args = new ResultEventArgs()
                    {
                        FromClientId = dispatch.fromClient,
                        ToClientId   = dispatch.toClient,
                        RunId        = dispatch.runId
                    };
                    var e = resultEvent;
                    if (e != null)
                    {
                        e.Invoke(args);
                    }
                }
            }
        }
コード例 #2
0
ファイル: Server.cs プロジェクト: himadriHK/vCompute
        private void sendToExecuteQueue(Payload payload)
        {
            string          runId    = payload.clientId + payload.runId;
            payloadDispatch dispatch = null;

            if (taskPayLoad.ContainsKey(runId))
            {
                dispatch = taskPayloadDispatch[runId];
            }
            else
            {
                dispatch            = new payloadDispatch();
                dispatch.fromClient = payload.clientId;
                dispatch.runId      = payload.clientId + payload.runId;
                dispatch.toClient   = clientList.Where(s => s.Name != payload.clientId).First().Name;
                taskPayloadDispatch.Add(runId, dispatch);
            }

            var toId = dispatch.toClient;

            payload.runId = dispatch.runId;
            if (payload.command == CommandType.REQUEST)
            {
                payload.command = CommandType.EXECUTE;
            }
            else if (payload.command == CommandType.APPEND_REQUEST)
            {
                payload.command = CommandType.APPEND_EXECUTE;
            }

            var Q = taskPayLoad[toId];

            Q.Enqueue(payload);
            if (payload.remainingPayloads == 0 && payload.isAppend == false)
            {
                ExectueEventArgs args = new ExectueEventArgs()
                {
                    FromClientId = payload.clientId,
                    ToClientId   = toId,
                    RunId        = runId
                };
                var e = executeEvent;
                if (e != null)
                {
                    e.Invoke(args);
                }
            }
        }