• Stars
    star
    97
  • Rank 336,496 (Top 7 %)
  • Language
    C#
  • License
    MIT License
  • Created over 8 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

C# Websockets for all platforms using native bridges

WebSockets.Pcl

WebSockets.PCL is a portable class library, profile 259, C# WebSocket implementation.

The motivation for this project was three part :

  1. Having a completely different websocket implementation on every platform is a pain.

  2. OkHttp.Ws Crashes with a fatal signal 11 if you loose internet

  3. My original Mono implementation could not support TLS or SSL (Because Mono is janky)

This project is a binding library that makes use of native websockets to get around the limitations and jank of mono based websockets. On IOS I use SocketRocket because it works fine. On Android I wrote a custom binding library in Java and use AndroidAsync. On the WP8 we wrap around Websockets4Net. On the other platforms we wrap the default MSDN implementation. Really the most valuable part is the android implementation... but why not unify ?

https://www.nuget.org/packages/Websockets.Pcl/

Platforms

  • Android
  • iOS
  • WP8
  • Universal
  • Xamarin
  • .Net Core
  • PCL

NuGet

https://www.nuget.org/packages/Websockets.Pcl/

Setup

Android

  • Include Websockets.Droid and Websockets (PCL) library

Ios

  • Include Websockets.Ios and Websockets (PCL) library
  • Include Square.SocketRocket

Xamarin Forms

  • Include the Websockets (PCL) library in the main common app
  • Include the platform specific stuff in the platform projects (Like Above)

.Net Core (MVC, Console, ect)

  • Include Websockets.Net and Websockets (PCL) library

Windows 10 Universal

  • Include Websockets.Universal and Websockets (PCL) library

Windows 8 Phone

  • Include Websockets.WP8 and Websockets (PCL) library
  • Include Websockets4Net

Usage

        void Configure()
        {
            // Call in your platform (non-pcl) startup            
            // 1) Link in your main activity or AppDelegate or whatever
            Websockets.Droid.WebsocketConnection.Link();
        }
        
        
        void Connect()
        {
            // 2) Get a websocket from your PCL library via the factory
            connection = Websockets.WebSocketFactory.Create();
            connection.OnOpened += Connection_OnOpened;
            connection.OnMessage += Connection_OnMessage;
        }

        void Send()
        {            
            connection.Open("http://echo.websocket.org");
            connection.Send("Hello World");
        }

        private void Connection_OnOpened()
        {
            Debug.WriteLine("Opened !");
        }

        private void Connection_OnMessage(string obj)
        {
            Echo = obj == "Hello World";
        }

Example

There are a few 'test' examples (projects with the Tests suffix). Take a look there. The relivent code is in a standalone test file.

TODO

  • Support other platforms. Will implement as requested.

Questions

Post onto the Github issue system or contact me via my website

More Repositories

1

Unity3d-Foundation

Unity3d Databinding, MVVM, Tasks, Localization
C#
282
star
2

Foundation-Light

Light Weight Architecture Library
C#
130
star
3

Unity3d-Databinding-Mvvm-Mvc

Unity3d uGUI Observable library for Mvvm / Mvc
63
star
4

TDAmeritrade.DotNetCore

TDAmeritrade for C# and DotNetCore
C#
54
star
5

Unity3d-Async-Task

Unity3d Foundation Async Task Library
42
star
6

DotNetCoreUnity3d

Simple high score and chat service using Dot Net Core and Unity3d
C#
38
star
7

Realtime.Messaging.Xamarin

Realtime.co websockets in Xamarin
C#
28
star
8

Unity3d-uGUI-Terminal

A simple terminal consol using uGUI for Unity3d
C#
27
star
9

Unity3d-Localization

Translation Tool for Unity5 and uGUI
24
star
10

Realtime-Unity3d

Realtime Ortc Messaging Plugin and Samples for Unity3d
C#
16
star
11

Blazor.Transitions

Blazor Transition Example
HTML
12
star
12

Unity3d-Event-Messenger

Listener pattern / Message Broker for Unity3d
11
star
13

WebSocket.Portable

C# Portable WebSocket Client Library (Rfc 6455). Works with Xamarin.
C#
11
star
14

Unity3d-Service-Injector

Inversion of control container for Unity3d
8
star
15

MVVMExample

MVVM Prototype for Unity3d
C#
5
star
16

Augmented-Reality-Ghost-Hunter

Augmented Reality Game Ghost Hunter Assets for Unity3d
C#
5
star
17

StockGame

Unity3d Stock Game
C#
4
star
18

BitSerializer

Minimal binary serializer
C#
3
star
19

ISeeYou-Augmented-Reality-Face-Recognition

Face Recognition Augmented Reality in Unity3d using Metaio SDK
3
star
20

Xamarin-Todo-Xaml

A Xamarin Forms Todo example application featuring xaml and databinding.
Assembly
2
star
21

Xamarin.Forms.AsyncImage

Image control with cache and spinner for Xamarin Forms
C#
2
star
22

FoundationJS

MVVM Framework for JS
JavaScript
1
star