private void ProccessPublish(AcceptedRequest tu, IncomingMessageEx request) { StatusCodes statusCode = StatusCodes.OK; int expires = request.Reader.GetExpires(600, 900); if (request.Reader.IsExpiresTooBrief(60)) { statusCode = StatusCodes.IntervalTooBrief; } int sipIfMatch = simpleModule.InvalidEtag; if (statusCode == StatusCodes.OK) { if (request.Reader.SipIfMatch.Length == 8) { if (HexEncoding.TryParseHex8(request.Reader.SipIfMatch.Bytes, request.Reader.SipIfMatch.Begin, out sipIfMatch) == false) { statusCode = StatusCodes.CallLegTransactionDoesNotExist; } } } if (statusCode == StatusCodes.OK) { var fromUser = request.Reader.From.AddrSpec.User.ToString(); var fromHost = request.Reader.From.AddrSpec.Hostport.Host.ToString(); if (simpleModule.Publish(fromUser + "@" + fromHost, ref sipIfMatch, expires, request.Content) == false) { statusCode = StatusCodes.BadRequest; } } var writer = GetWriter(); if (statusCode == StatusCodes.OK) { writer.WriteStatusLine(statusCode); writer.CopyViaToFromCallIdRecordRouteCSeq(request.Reader, statusCode); writer.WriteExpires(expires); writer.WriteSipEtag(sipIfMatch); writer.WriteCRLF(); } else { writer.WriteResponse(request.Reader, statusCode); } SendResponse(request, writer); }
public override HttpMessageWriter ProcessPutItem(ByteArrayPart username, ByteArrayPart domain, HttpMessageReader reader, ArraySegment <byte> content) { var statusCode = StatusCodes.OK; int sipIfMatch = simpleModule.InvalidEtag; if (reader.Count.IfMatches > 0) { if (HexEncoding.TryParseHex8(reader.IfMatches[0].Bytes, reader.IfMatches[0].Begin, out sipIfMatch) == false) { statusCode = StatusCodes.PreconditionFailed; } } if (statusCode == StatusCodes.OK) { if (simpleModule.Publish(username.ToString() + "@" + domain.ToString(), ref sipIfMatch, 60, content) == false) { statusCode = StatusCodes.BadRequest; } } HttpMessageWriter response; if (statusCode != StatusCodes.OK) { response = CreateResponse(statusCode); } else { response = CreateNotFinishedResponse(statusCode, ContentType.None); response.WriteEtag(sipIfMatch); response.WriteCRLF(); } return(response); }