private CmdRequest ReadRequest(NetworkStream stream) { CmdRequest request = null; JsonSerializer serializer = new JsonSerializer(); using (JsonReader reader = new BsonReader(stream)) { request = serializer.Deserialize<CmdRequest>(reader); reader.Close(); } return request; }
public void CloseInput() { MemoryStream ms = new MemoryStream(); BsonReader reader = new BsonReader(ms); Assert.IsTrue(ms.CanRead); reader.Close(); Assert.IsFalse(ms.CanRead); ms = new MemoryStream(); reader = new BsonReader(ms) { CloseInput = false }; Assert.IsTrue(ms.CanRead); reader.Close(); Assert.IsTrue(ms.CanRead); }
private void InternalClientThread(object socketObject) { CmdServerReply reply = null; Socket clientSocket = socketObject as Socket; if (clientSocket != null) { try { using (NetworkStream stream = new NetworkStream(clientSocket)) { using (BsonReader reader = new BsonReader(stream)) { JsonSerializer serializer = new JsonSerializer(); reply = serializer.Deserialize<CmdServerReply>(reader); reader.Close(); } stream.Close(); } } catch (Exception ex) { reply = null; Logger.AddError("Failed to receive reply from the checker", ex); } } if (reply != null) { SendCmdReply(reply); } }