Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dynajoe/socket.io-csharp-client
https://github.com/dynajoe/socket.io-csharp-client
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dynajoe/socket.io-csharp-client
- Owner: dynajoe
- Created: 2012-10-16T22:37:16.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-05-09T18:49:42.000Z (over 11 years ago)
- Last Synced: 2024-04-15T02:15:11.493Z (9 months ago)
- Language: C#
- Size: 528 KB
- Stars: 7
- Watchers: 2
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# C# Socket.IO client
A simple C# implementation of the Socket.IO client using [WebSocket4Net](http://websocket4net.codeplex.com/).*DISCLAIMER: This is not a complete implementation of the Socket.IO client. There are lots of missing parts. Please feel free to submit a pull-request to add whatever feature is missing that you need.*
## Usage
#### Server
```JavaScript
var io = require("socket.io").listen(3000);io.sockets.on("connection", function (socket) {
socket.on("data", function (data) {
console.log("Client sent: " + data);
if (data) {
socket.emit("data", data.toUpperCase(), { length: data.length });
}
});
});
```Start the server by running ```npm install``` then ```node index.js``` from the ```Example/Server``` directory.
#### Client
```CSharp
using System;
using SocketIO.Client;namespace SimpleClient
{
class Example
{
static void Main()
{
var io = new SocketIOClient();
var socket = io.Connect("http://localhost:3000/");socket.On("data", (args, callback) =>
{
Console.WriteLine("Server sent:");for (int i = 0; i < args.Length; i++)
{
Console.WriteLine("[" + i + "] => " + args[i]);
}
});
string line;
while ((line = Console.ReadLine()) != "q")
{
socket.Emit("data", line);
}
}
}
}
```Run the C# client and interact with the server by typing anything into the console.