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); }
public GetObjectAction(RequestContext client, string path) : base(client) { Path = path; }
public UserAction(RequestContext client) { Client = client; }
public DoScriptAction(RequestContext client, string trigger, string effect) : base(client) { Trigger = trigger; Effect = effect; }
public PutObjectAction(RequestContext client, string path, DObject value) : base(client) { Path = path; Value = value; }
public void Dispatch(UserAction request, RequestContext context) { Console.WriteLine("enqueuing request on work queue"); _workQueue.Enqueue(new WorkItem { Issuer = context, Request = request }); }