private void SendAnswer(Body body, HttpListenerContext ctx) { try { lock (sendBuffer) { foreach (var node in sendBuffer) { body.AddChild(node); if (node.Namespace == Uri.STREAM) body.SetAttribute("xmlns:stream", Uri.STREAM); } if (closed) body.Type = BoshType.terminate; BoshXmppHelper.SendAndCloseResponse(ctx, body.ToString(), true, null); sendBuffer.Clear(); log.DebugFormat("Connection {0} Send buffer:\r\n{1}", Id, body); } } catch (Exception e) { //BUG: Я думаю баг тут из за обрыва соединения при говенном кач-ве соединения. log.DebugFormat("Connection {0} Error send buffer: {1}", Id, e); Close(); } }
private Body WriteBodyHeaders(Body body) { if (string.IsNullOrEmpty(body.Sid)) { body.Sid = Id; body.Secure = false; } body.Ack = body.Rid != 0 ? body.Rid : rid; body.RemoveAttribute("rid"); body.To = null; if (body.HasAttribute("xmpp:version") || body.HasAttribute("xmpp:restart")) { body.SetAttribute("xmlns:xmpp", "urn:xmpp:xbosh"); } body.RemoveAllChildNodes(); return body; }