private void Message(object sender, DdpMessage e) { if (e.Body["collection"] == null) { return; } if (e.Body["collection"].ToObject <string>() != Name) { return; } switch (e.Msg) { case "added": HandleAdded(e.Get <SubAddedModel <T> >()); break; case "changed": HandleChanged(e.Get <SubChangedModel <T> >()); break; case "removed": HandleRemoved(e.Get <SubRemovedModel>()); break; case "addedBefore": HandleAddedBefore(e.Get <SubAddedBeforeModel <T> >()); break; case "movedBefore": HandleMovedBefore(e.Get <SubMovedBeforeModel>()); break; } }
protected virtual void OnMessageReceived(string data) { JObject body = JObject.Parse(data); if (body["msg"] == null) { return; } string msg = body["msg"].ToObject <string>(); DdpMessage?.Invoke(this, new DdpMessage(msg, data)); }
private void OnMessageAdv(object sender, MessageEventArgs e) { JObject body = JObject.Parse(e.Data); if (body["msg"] == null) { return; } string msg = body["msg"].ToObject <string>(); DdpMessage?.Invoke(this, new DdpMessage(msg, e.Data)); }
private void OnDdpMessage(object sender, DdpMessage ddpMessage) { if (ddpMessage.Msg == "result" && ddpMessage.Body["id"].ToObject <string>() == Id) { _webSocketAdapterBase.DdpMessage -= OnDdpMessage; JObject body = ddpMessage.Body; if (body["error"] == null) { _callback(null, body["result"].ToObject <T>()); } else { _callback(body["error"].ToObject <DetailedError>(), default(T)); } } }
private void Message(object sender, DdpMessage e) { switch (e.Msg) { case "nosub": HandleNoSub(e.Get <NoSubModel>()); break; case "ready": SubReadyModel ready = e.Get <SubReadyModel>(); if (ready.Subs.Contains(Id)) { HandleReady(); } break; } }
private void WebSocketMessage(object sender, DdpMessage e) { switch (e.Msg) { case "connected": case "failed": HandleConnect(e.Msg == "connected", e.Get <JToken>()); break; case "ping": HandlePing(e.Get <PingModel>()); break; case "pong": HandlePong(e.Get <PongModel>()); break; case "result": HandleMethod(e.Get <MethodResponse>()); break; } }