Skip to content

Commit

Permalink
Parsing of location string to determine port
Browse files Browse the repository at this point in the history
  • Loading branch information
statianzo committed Nov 9, 2010
1 parent 9faebab commit a2e29c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Samples/ConsoleApp/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Server
static void Main()
{
var allSockets = new List<WebSocketConnection>();
var server = new WebSocketServer(8181, "ws://localhost:8181");
var server = new WebSocketServer("ws://localhost:8181");
server.Start(socket =>
{
socket.OnOpen = () =>
Expand Down
2 changes: 1 addition & 1 deletion readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Example

The following is an example that will echo to a client.

var server = new WebSocketServer(8181, "ws://localhost:8181");
var server = new WebSocketServer("ws://localhost:8181");
server.Start(socket =>
{
socket.OnOpen = () => Console.WriteLine("Open!");
Expand Down
6 changes: 6 additions & 0 deletions src/Fleck/WebSocketServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ public class WebSocketServer : IDisposable
{
private Action<WebSocketConnection> _config;

public WebSocketServer(string location)
{
var uri = new Uri(location);
Port = uri.Port > 0 ? uri.Port : 8181;
Location = location;
}
public WebSocketServer(int port, string location)
{
Port = port;
Expand Down

0 comments on commit a2e29c6

Please sign in to comment.