本文整理汇总了C#中WsFrame类的典型用法代码示例。如果您正苦于以下问题:C# WsFrame类的具体用法?C# WsFrame怎么用?C# WsFrame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WsFrame类属于命名空间,在下文中一共展示了WsFrame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: processClose
private bool processClose(WsFrame frame)
{
if (!frame.IsClose)
return false;
#if DEBUG
Console.WriteLine("WS: [email protected]: Start closing handshake.");
#endif
close(frame.PayloadData);
return true;
}
示例2: processFrame
private bool processFrame(WsFrame frame)
{
return frame.IsCompressed && _compression == CompressionMethod.NONE
? processUnsupportedFrame (
frame,
CloseStatusCode.INCORRECT_DATA,
"A compressed data has been received without available decompression method.")
: frame.IsFragmented
? processFragmentedFrame (frame)
: frame.IsData
? processDataFrame (frame)
: frame.IsPing
? processPingFrame (frame)
: frame.IsPong
? processPongFrame ()
: frame.IsClose
? processCloseFrame (frame)
: processUnsupportedFrame (frame, CloseStatusCode.POLICY_VIOLATION, null);
}
示例3: processUnsupportedFrame
private bool processUnsupportedFrame(WsFrame frame, CloseStatusCode code, string reason)
{
_logger.Debug ("Unsupported frame:\n" + frame.PrintToString (false));
processException (new WebSocketException (code, reason), null);
return false;
}
示例4: processCloseFrame
private bool processCloseFrame(WsFrame frame)
{
var payload = frame.PayloadData;
close (payload, !payload.ContainsReservedCloseStatusCode, false);
return false;
}
示例5: processFragmentedFrame
private bool processFragmentedFrame(WsFrame frame)
{
return frame.IsContinuation // Not first fragment
? true
: processFragments (frame);
}
示例6: acceptFrame
private bool acceptFrame(WsFrame frame)
{
return frame.IsCompressed && _compression == CompressionMethod.None
? acceptUnsupportedFrame (
frame,
CloseStatusCode.IncorrectData,
"A compressed data has been received without available decompression method.")
: frame.IsFragmented
? acceptFragmentedFrame (frame)
: frame.IsData
? acceptDataFrame (frame)
: frame.IsPing
? acceptPingFrame (frame)
: frame.IsPong
? acceptPongFrame (frame)
: frame.IsClose
? acceptCloseFrame (frame)
: acceptUnsupportedFrame (frame, CloseStatusCode.PolicyViolation, null);
}
示例7: acceptPongFrame
private bool acceptPongFrame(WsFrame frame)
{
_receivePong.Set ();
_logger.Trace ("Received a Pong.");
return true;
}
示例8: processFragmented
private bool processFragmented(WsFrame frame)
{
// Not first fragment
if (frame.IsContinuation)
return true;
// Not fragmented
if (frame.IsFinal)
return false;
bool incorrect = !frame.IsData ||
(frame.IsCompressed && _compression == CompressionMethod.NONE);
if (!incorrect)
processFragments (frame);
else
processIncorrectFrame ();
return true;
}
示例9: processFrame
private void processFrame(WsFrame frame)
{
bool processed = processAbnormal (frame) ||
processFragmented (frame) ||
processData (frame) ||
processPing (frame) ||
processPong (frame) ||
processClose (frame);
if (!processed)
processIncorrectFrame ();
}
示例10: processClose
private bool processClose(WsFrame frame)
{
if (!frame.IsClose)
return false;
_logger.Trace ("Start closing handshake.");
close (frame.PayloadData);
return true;
}
示例11: processData
private bool processData(WsFrame frame)
{
if (!frame.IsData)
return false;
if (frame.IsCompressed && _compression == CompressionMethod.NONE)
return false;
var args = frame.IsCompressed
? new MessageEventArgs (
frame.Opcode, frame.PayloadData.ApplicationData.Decompress (_compression))
: new MessageEventArgs (frame.Opcode, frame.PayloadData);
OnMessage.Emit (this, args);
return true;
}
示例12: processAbnormal
private bool processAbnormal(WsFrame frame)
{
if (frame != null)
return false;
_logger.Trace ("Start closing handshake.");
var code = CloseStatusCode.ABNORMAL;
Close (code, code.GetMessage ());
return true;
}
示例13: processPong
private bool processPong(WsFrame frame)
{
if (!frame.IsPong)
return false;
#if DEBUG
Console.WriteLine("WS: [email protected]: Receive Pong.");
#endif
_receivePong.Set();
return true;
}
示例14: processPing
private bool processPing(WsFrame frame)
{
if (!frame.IsPing)
return false;
#if DEBUG
Console.WriteLine("WS: [email protected]: Return Pong.");
#endif
pong(frame.PayloadData);
return true;
}
示例15: acceptDataFrame
private bool acceptDataFrame(WsFrame frame)
{
var args = frame.IsCompressed
? new MessageEventArgs (
frame.Opcode, frame.PayloadData.ApplicationData.Decompress (_compression))
: new MessageEventArgs (frame.Opcode, frame.PayloadData);
if (_readyState == WebSocketState.Open)
OnMessage.Emit (this, args);
return true;
}