コード例 #1
0
ファイル: Request.cs プロジェクト: markchipman/echo-process
        public static Either <string, Req> Create(ClientConnectionId id, ClientMessageId msgId, ProcessId to, ProcessId sender, string msg, Map <ClientConnectionId, ClientConnection> clientConnections)
        {
            if (!to.IsValid)
            {
                return("Invalid process-id (To)");
            }
            var conn = clientConnections.Find(id);

            if (conn.IsNone)
            {
                return("Invalid connection-id");
            }

            var msgObj = (from type in validMessageTypes(to)
                          let obj = Deserialise.Object(msg, type)
                                    where obj != null
                                    select obj)
                         .FirstOrDefault();

            if (msgObj == null)
            {
                return("Message incompatible with the inbox message type");
            }

            return(new AskReq(id, msgId, to, sender, msgObj, conn.IfNone(() => null)));
        }
コード例 #2
0
        public int Incoming(SessionAction incoming)
        {
            if (incoming.SystemName == system.Value && incoming.NodeName == nodeName.Value)
            {
                return(0);
            }

            switch (incoming.Tag)
            {
            case SessionActionTag.Touch:
                Touch(incoming.SessionId);
                break;

            case SessionActionTag.Start:
                Start(incoming.SessionId, incoming.Timeout, Map <string, object>());
                break;

            case SessionActionTag.Stop:
                Stop(incoming.SessionId);
                break;

            case SessionActionTag.SetData:
                var type = Type.GetType(incoming.Type);
                if (type == null)
                {
                    logErr("Session-value type not found: " + incoming.Type);
                }
                else
                {
                    var value = Deserialise.Object(incoming.Value, type);
                    if (value == null)
                    {
                        logErr("Session-value is null or failed to deserialise: " + incoming.Value);
                    }
                    else
                    {
                        SetData(incoming.SessionId, incoming.Key, value, incoming.Time);
                    }
                }
                break;

            case SessionActionTag.ClearData:
                ClearData(incoming.SessionId, incoming.Key, incoming.Time);
                break;

            default:
                return(0);
            }
            return(1);
        }