本文整理汇总了C#中INextFilter.MessageReceived方法的典型用法代码示例。如果您正苦于以下问题:C# INextFilter.MessageReceived方法的具体用法?C# INextFilter.MessageReceived怎么用?C# INextFilter.MessageReceived使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INextFilter
的用法示例。
在下文中一共展示了INextFilter.MessageReceived方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MessageReceived
/// <inheritdoc/>
public override void MessageReceived(INextFilter nextFilter, IoSession session, Object message)
{
//if (log.IsDebugEnabled)
// log.DebugFormat("Processing a MESSAGE_RECEIVED for session {0}", session.Id);
IoBuffer input = message as IoBuffer;
if (input == null)
{
nextFilter.MessageReceived(session, message);
return;
}
IProtocolDecoder decoder = _factory.GetDecoder(session);
IProtocolDecoderOutput decoderOutput = GetDecoderOut(session, nextFilter);
// Loop until we don't have anymore byte in the buffer,
// or until the decoder throws an unrecoverable exception or
// can't decoder a message, because there are not enough
// data in the buffer
while (input.HasRemaining)
{
Int32 oldPos = input.Position;
try
{
// TODO may not need lock on UDP
lock (session)
{
// Call the decoder with the read bytes
decoder.Decode(session, input, decoderOutput);
}
// Finish decoding if no exception was thrown.
decoderOutput.Flush(nextFilter, session);
}
catch (Exception ex)
{
ProtocolDecoderException pde = ex as ProtocolDecoderException;
if (pde == null)
pde = new ProtocolDecoderException(null, ex);
if (pde.Hexdump == null)
{
// Generate a message hex dump
Int32 curPos = input.Position;
input.Position = oldPos;
pde.Hexdump = input.GetHexDump();
input.Position = curPos;
}
decoderOutput.Flush(nextFilter, session);
nextFilter.ExceptionCaught(session, pde);
// Retry only if the type of the caught exception is
// recoverable and the buffer position has changed.
// We check buffer position additionally to prevent an
// infinite loop.
if (!(ex is RecoverableProtocolDecoderException) || input.Position == oldPos)
break;
}
}
}
示例2: MessageReceived
/// <inheritdoc/>
public virtual void MessageReceived(INextFilter nextFilter, IoSession session, Object message)
{
nextFilter.MessageReceived(session, message);
}
示例3: MessageReceived
/// <inheritdoc/>
public override void MessageReceived(INextFilter nextFilter, IoSession session, Object message)
{
try
{
if (_messageFactory.IsRequest(session, message))
{
Object pongMessage = _messageFactory.GetResponse(session, message);
if (pongMessage != null)
nextFilter.FilterWrite(session, new DefaultWriteRequest(pongMessage));
}
if (_messageFactory.IsResponse(session, message))
ResetStatus(session);
}
finally
{
if (!IsKeepAliveMessage(session, message))
nextFilter.MessageReceived(session, message);
}
}
示例4: MessageReceived
public override void MessageReceived(INextFilter nextFilter, IoSession session, Object message)
{
test.testResult += id + "MR";
nextFilter.MessageReceived(session, message);
}
示例5: MessageReceived
public void MessageReceived(INextFilter nextFilter, IoBuffer buf)
{
lock (this)
{
_currentNextFilter = nextFilter;
_sessionStream.Write(buf);
if (_authenticated)
{
IoBuffer readBuffer = ReadBuffer();
nextFilter.MessageReceived(_session, readBuffer);
}
}
}
示例6: MessageReceived
/// <inheritdoc/>
public override void MessageReceived(INextFilter nextFilter, IoSession session, Object message)
{
Profile(_profileMessageReceived, _messageReceivedTimerWorker, () => nextFilter.MessageReceived(session, message));
}
示例7: MessageReceived
public override void MessageReceived(INextFilter nextFilter, IoSession session, Object message)
{
result += "F";
nextFilter.MessageReceived(session, message);
}
示例8: Flush
public override void Flush(INextFilter nextFilter, IoSession session)
{
IQueue<Object> messageQueue = MessageQueue;
while (!messageQueue.IsEmpty)
{
nextFilter.MessageReceived(session, messageQueue.Dequeue());
}
}
示例9: MessageReceived
public override void MessageReceived(INextFilter nextFilter, IoSession session, object message)
{
using (var scope = ObjectHost.Host.BeginLifetimeScope())
{
var commandMessage = message as DuplexMessage;
if (commandMessage != null)
{
if (commandMessage.Header.CommandCode == CommandCode.Authentication)
{
var school = metaRepository
.GetAllSchools()
.ByIdentifier(commandMessage.Header.Identifier);
if (school != null && school.UniqueToken.Equals(
commandMessage.GetContent<AuthInfo>().Mac, StringComparison.OrdinalIgnoreCase))
{
session.SetAttributeIfAbsent(KeyName.SESSION_IDENTIFIER, commandMessage.Header.Identifier);
identifierManager.SetSessonIdentifier(commandMessage.Header.Identifier, session);
nextFilter.FilterWrite(session,
new DefaultWriteRequest(
DuplexMessage.CreateCallbackMessage(commandMessage)));
}
else
{
nextFilter.FilterWrite(session,
new DefaultWriteRequest(
DuplexMessage.CreateAckMessage(commandMessage, ErrorCode.AuthenticationFailed)));
}
}
else if (
commandMessage.Header.CommandCode == CommandCode.Register ||
commandMessage.Header.CommandCode == CommandCode.Heartbeat)
{
nextFilter.MessageReceived(session, message);
}
else
{
if (!session.ContainsAttribute(KeyName.SESSION_IDENTIFIER))
{
nextFilter.FilterWrite(session, new DefaultWriteRequest(
DuplexMessage.CreateAckMessage(commandMessage, ErrorCode.UnauthorizedCommand)));
}
else
{
var identifier = session.GetAttribute<string>(KeyName.SESSION_IDENTIFIER);
if (identifier.Equals(commandMessage.Header.Identifier))
nextFilter.MessageReceived(session, message);
else
{
nextFilter.FilterWrite(session, new DefaultWriteRequest(
DuplexMessage.CreateAckMessage(commandMessage, ErrorCode.UnauthorizedCommand)));
}
}
}
}
else
{
nextFilter.FilterWrite(session, new DefaultWriteRequest(
DuplexMessage.CreateAckMessage(
Guid.NewGuid().ToByteArray().ToBase64(),
MessageVersion.V1,
CommandCode.UnAssigned,
ErrorCode.IllegalCommandRequest)));
}
}
}