Skip to content

brunofcat/Xamarin.Socket.IO

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 

Repository files navigation

Xamarin.Socket.IO (beta)

this version doesn't currently work with socket.io 1.X - please use socket.io 0.9.X while this repo gets updated

C# interface for socket.io on mobile platforms.

This library uses WebSocket4Net for the websocket connections, and Newtonsoft.Json to serialize the objects passed through the socket.

##Running the Test app (OSX)

#####Set up the local server

  • Install node: you can install this via brew (see bottom of the page for install script, then run brew install node)
  • Navigate to the server directory and run npm install
  • run node app.js (If you run into a module.js exception in socket.io, see the following fix)

#####Restore the NuGet packages

  • Right-click on references and select "Restore NuGet Packages"

#####Run the app

  • Set the Socket.IO.Test project to be the startup project

##API

The basics

var socket = new SocketIO (host: "www.example.com", port: 80);

var connectionStatus = await socket.ConnectAsync ();

if (connectionStatus == ConnectionStatus.Connected) {
  socket.Emit ("MessageName", new Foo [] { new Foo () }); //emit message named "MessageName" with args a list of Foos
  socket.On ("MessageReceived", (data) => {               //call this lambda when a message named "MessageReceived"
    Console.WriteLine (data ["jsonFieldName"]);     //is emitted from the server
  });
} else {
  Console.WriteLine ("Websocket failed to connect to the server");
}

socket.Disconnect ();

*Note that data is a JToken.

About

C# socket.io Client for mobile

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 86.0%
  • PowerShell 11.7%
  • JavaScript 2.3%