예제 #1
0
파일: Server.cs 프로젝트: vogon/Demotic
        private void MakeActionAndDispatch(Message msg, MessageChannel channel)
        {
            UserAction request = null;
            RequestContext context = new RequestContext(channel, msg.SequenceNumber);

            if (msg.OpCode == MessageOpCode.GetObject)
            {
                string path = GetString(msg, "path");

                if (path == null) context.NegativeAcknowledge();

                request = new GetObjectAction(context, path);
            }
            else if (msg.OpCode == MessageOpCode.PutObject)
            {
                string path = GetString(msg, "path");
                DObject value = GetObject(msg, "value");

                if (path == null) context.NegativeAcknowledge();
                if (value == null) context.NegativeAcknowledge();

                request = new PutObjectAction(context, path, value);
            }
            else if (msg.OpCode == MessageOpCode.DoScript)
            {
                string trigger = GetString(msg, "when");
                string body = GetString(msg, "do");

                if (trigger == null) context.NegativeAcknowledge();
                if (body == null) context.NegativeAcknowledge();

                request = new DoScriptAction(context, trigger, body);
            }
            else if (msg.OpCode == MessageOpCode.NG ||
                     msg.OpCode == MessageOpCode.OK ||
                     msg.OpCode == MessageOpCode.Quote)
            {
                // drop it on the floor; not expecting these.
                return;
            }
            else
            {
                throw new NotImplementedException();
            }

            Debug.Assert(request != null);
            _worker.Dispatch(request, context);
        }
예제 #2
0
파일: UserAction.cs 프로젝트: vogon/Demotic
 public GetObjectAction(RequestContext client, string path)
     : base(client)
 {
     Path = path;
 }
예제 #3
0
파일: UserAction.cs 프로젝트: vogon/Demotic
 public UserAction(RequestContext client)
 {
     Client = client;
 }
예제 #4
0
파일: UserAction.cs 프로젝트: vogon/Demotic
 public DoScriptAction(RequestContext client, string trigger, string effect)
     : base(client)
 {
     Trigger = trigger;
     Effect = effect;
 }
예제 #5
0
파일: UserAction.cs 프로젝트: vogon/Demotic
 public PutObjectAction(RequestContext client, string path, DObject value)
     : base(client)
 {
     Path = path;
     Value = value;
 }
예제 #6
0
파일: Worker.cs 프로젝트: vogon/Demotic
 public void Dispatch(UserAction request, RequestContext context)
 {
     Console.WriteLine("enqueuing request on work queue");
     _workQueue.Enqueue(new WorkItem { Issuer = context, Request = request });
 }