public void Publish(Request request, IResponseHandler responseHandler) { if (request.type.Equals(RequestType.PUBLISH)) { Command command = Command.PUBLISH; if (request.persist) { command = Command.PERSIST; } int sequenceNumber = Frame.GenerateSequenceNumber(); FrameUtils frameUtils = new FrameUtils(command, sequenceNumber); frameUtils.AddVSKeyPairGetUtils("uri", request.uri); if (request.persist) { frameUtils.SetCommandGetUtils(Command.PERSIST); } else { frameUtils.SetCommandGetUtils(Command.PUBLISH); } frameUtils.AddVSKeyPairGetUtils("persist", request.persist.ToString()); if (request.expiry > 0) { frameUtils.AddVSKeyPairGetUtils("expiry", request.expiry.ToString("yyyy-MM-dd'T'HH:mm:ssK")); } if (request.expiryDelta > 0) { frameUtils.AddVSKeyPairGetUtils("expiryDelta", string.Format("{0}ms", request.expiryDelta)); } if (request.primaryAccessChain != null) { frameUtils.AddVSKeyPairGetUtils("primary_access_chain", request.primaryAccessChain); } frameUtils.AddVSKeyPairGetUtils("doverify", request.ifVerify.ToString()); if (!request.elaborationLevel.Equals(ChainLevel.UNSPECIFIED)) { frameUtils.AddVSKeyPairGetUtils("elaborate_pac", request.elaborationLevel.ToString().ToLower()); } if (request.autoChain) { frameUtils.AddVSKeyPairGetUtils("autochain", "true"); } foreach (RoutingObject routingObject in request.routingObjects) { frameUtils.AddRoutingObjectGetUtils(routingObject); } foreach (PayloadObject payloadObject in request.payloadObjects) { frameUtils.AddPayloadObjectGetUtils(payloadObject); } Frame publishFrame = frameUtils.Build(); publishFrame.Write(Controller.Instance.outputStream); Controller.Instance.outputStream.Flush(); ActivateResponseHandler(sequenceNumber, responseHandler); } }