Skip to content

Commit 9b91bc5

Browse files
committed
updated README.md
1 parent b7461c5 commit 9b91bc5

File tree

3 files changed

+85
-5
lines changed

3 files changed

+85
-5
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013 Jim Stott
3+
Copyright (c) 2013 J. Stott
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,78 @@
1-
socketio4net
2-
============
3-
4-
SocketIO4Net provides a .NET v4.0 & v4.5 (C#) client for Socket.IO.
1+
socketio4net
2+
============
3+
4+
SocketIO4Net.Client provides a .NET 4.0 & v4.5 (C#) client for Socket.IO. It provides an overall interface similar to a client JavaScript experience, leveraging the WebSocket4Net project for an underlying websocket implementation.
5+
6+
My goal for this project is a simple & familiar experience for .net clients. You know you want your .Net app to join in some of the fun, right? Besides, all the cool kids are using Nodejs and Socket.IO these days anyway, give it a whirl.
7+
8+
## Development Branch
9+
10+
The Development branch contains wip code that incorporates xhr-polling in addition to websocket support. A new webserver & client dashboard has also been added into the samples in samples/node.sever.
11+
12+
From VS2012/VS2013, compile and start the the Samples/Console_Events project after you have started the samples/node.server.
13+
14+
*In order to run the samples/node.server dashboard - you will need to run `npm install` in that directory initially.*
15+
16+
* `install.cmd` will run npm install for you
17+
* `startServer.cmd` will then run the nodejs server, and launch a chrome browser window to http://localhost:3000
18+
* `debugServer.cmd` will run node-inspector and launch chrome browser and allow you to run a debug session against the server
19+
20+
* At this time, Nuget packages have not yet been updated
21+
22+
This resulting signature is very similar to the socket.io javascript counterpart:
23+
24+
## node.js / JavaScript client
25+
````
26+
socket.on('news', function (data) {
27+
console.log(data);
28+
});
29+
````
30+
## C# .net client
31+
````
32+
socket.On("news", (data) => {
33+
Console.WriteLine(data);
34+
});
35+
````
36+
The all important - Sample / Demo code snippet
37+
38+
Client socket;
39+
public void Execute()
40+
{
41+
Console.WriteLine("Starting TestSocketIOClient Example...");
42+
43+
socket = new Client("http://127.0.0.1:3000/"); // url to nodejs
44+
socket.Opened += SocketOpened;
45+
socket.Message += SocketMessage;
46+
socket.SocketConnectionClosed += SocketConnectionClosed;
47+
socket.Error += SocketError;
48+
49+
// register for 'connect' event with io server
50+
socket.On("connect", (fn) =>
51+
{
52+
Console.WriteLine("\r\nConnected event...\r\n");
53+
Console.WriteLine("Emit Part object");
54+
55+
// emit Json Serializable object, anonymous types, or strings
56+
Part newPart = new Part()
57+
{ PartNumber = "K4P2G324EC", Code = "DDR2", Level = 1 };
58+
socket.Emit("partInfo", newPart);
59+
});
60+
61+
// register for 'update' events - message is a json 'Part' object
62+
socket.On("update", (data) =>
63+
{
64+
Console.WriteLine("recv [socket].[update] event");
65+
//Console.WriteLine(" raw message: {0}", data.RawMessage);
66+
//Console.WriteLine(" string message: {0}", data.MessageText);
67+
//Console.WriteLine(" json data string: {0}", data.Json.ToJsonString());
68+
//Console.WriteLine(" json raw: {0}", data.Json.Args[0]);
69+
70+
// cast message as Part - use type cast helper
71+
Part part = data.Json.GetFirstArgAs<Part>();
72+
Console.WriteLine(" Part Level: {0}\r\n", part.Level);
73+
});
74+
75+
// make the socket.io connection
76+
socket.Connect();
77+
}
78+

SocketIO4Net.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Node-Server", "samples\node
1818
EndProject
1919
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console_Events", "samples\client.events\Console_Events.csproj", "{F2CE5E48-E58C-4B96-A27A-697F4588B593}"
2020
EndProject
21+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CB9333AA-E019-41CA-B631-A1569438FBA7}"
22+
ProjectSection(SolutionItems) = preProject
23+
LICENSE = LICENSE
24+
README.md = README.md
25+
EndProjectSection
26+
EndProject
2127
Global
2228
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2329
Debug|Any CPU = Debug|Any CPU

0 commit comments

Comments
 (0)