Giter Site home page Giter Site logo

mocket-io's Introduction

Mocket.IO

Build Status

A partial mock of Socket.IO for use with Incubator projects

##Usage

###Creating Client- and Server-side socket interfaces var mocket = require("mocket-io");

var server = new mocket.Server();
var client = new mocket.Client(server);

var clientSocket;
var serverSocket;

server.once("connection", function (socket) {
    serverSocket = socket;
});

clientSocket = client.connect();

####More compact: client-only var mocket = require("mocket-io");

var client = new mocket.Client(new mocket.Server());

var clientSocket = client.connect();

###Subscribing to a message type anySocket.on("persistentEventType", callback); anySocket.once("oneTimeEventType", callback);

###Sending a message to the server serverSocket.on("messageType", function (message) { console.log(message); }); clientSocket.emit("messageType", "message");

###Joining a room serverSocket.join("roomName");

###Sending a message to a room serverSocket.to("roomName").emit("messageType", "message");

###Unsubscribing a handler anySocket.off("eventType", oldHandler);

###Unsubscribing all handlers anySocket.off("eventType");

mocket-io's People

Contributors

a-type avatar jagoda avatar carpeliam avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.