Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocketserver broadcast send raw data #250

Open
wants to merge 2 commits into
base: v1.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Protocols/WebSocket/WebSocketServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public WebSocketServer(IEnumerable<ISubProtocol<TWebSocketSession>> subProtocols
public WebSocketServer(ISubProtocol<TWebSocketSession> subProtocol)
: this(new List<ISubProtocol<TWebSocketSession>> { subProtocol })
{

}

/// <summary>
Expand Down Expand Up @@ -244,7 +244,7 @@ private bool SetupSubProtocols(IServerConfig config)
{
string originalProtocolName = protocolConfig.Name;
string protocolName;

ISubProtocol<TWebSocketSession> subProtocolInstance;

if (!string.IsNullOrEmpty(originalProtocolName))
Expand Down Expand Up @@ -328,7 +328,7 @@ private bool SetupSubProtocols(IServerConfig config)
return false;
}
}

return true;
}

Expand Down Expand Up @@ -652,7 +652,7 @@ protected override bool SetupCommands(Dictionary<string, ICommand<TWebSocketSess
var commands = new List<ICommand<TWebSocketSession, IWebSocketFragment>>
{
new HandShake<TWebSocketSession>(),
new Text<TWebSocketSession>(),
new Text<TWebSocketSession>(),
new Binary<TWebSocketSession>(),
new Close<TWebSocketSession>(),
new Ping<TWebSocketSession>(),
Expand Down Expand Up @@ -772,7 +772,8 @@ private void SendRawDataToSession(object state)

try
{
sendOk = session.TrySendRawData(param.Data);
session.SendRawData(param.Data);
sendOk = true;
}
catch (Exception e)
{
Expand Down
9 changes: 9 additions & 0 deletions Protocols/WebSocket/WebSocketSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,15 @@ bool IWebSocketSession.TrySendRawData(byte[] data, int offset, int length)
return base.TrySend(new ArraySegment<byte>(data, offset, length));
}

/// <summary>
/// Sends raw data segments.
/// </summary>
/// <param name="segments">The segments.</param>
internal void SendRawData(IList<ArraySegment<byte>> segments)
{
base.Send(segments);
}

/// <summary>
/// Tries the send raw data segments.
/// </summary>
Expand Down