All Projects → charleslxh → React Socket Io

charleslxh / React Socket Io

Licence: apache-2.0
A react provider for socket.io, http://socket.io/

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Socket Io

socket.io-client-core
High-Performance Socket.IO client in C#
Stars: ✭ 70 (-36.94%)
Mutual labels:  socket, socketio
Angular Ngrx Socket Frontend
Angular Ngrx Socket.IO Example
Stars: ✭ 177 (+59.46%)
Mutual labels:  socket, socketio
Node Decorators
node-decorators
Stars: ✭ 230 (+107.21%)
Mutual labels:  socket, socketio
SocketIOUnity
A Wrapper for socket.io-client-csharp to work with Unity.
Stars: ✭ 69 (-37.84%)
Mutual labels:  socket, socketio
Chatroom
vue2聊天室,图灵机器人,node爬虫
Stars: ✭ 103 (-7.21%)
Mutual labels:  socket, socketio
Mean Angular4 Chat App
MEAN stack with Angular 4 Chat App
Stars: ✭ 41 (-63.06%)
Mutual labels:  socket, socketio
Bizsocket
异步socket,对一些业务场景做了支持
Stars: ✭ 469 (+322.52%)
Mutual labels:  socket, socketio
Chatroom Vue
一个简单的多人聊天室。基于vue和node+Socket.IO
Stars: ✭ 71 (-36.04%)
Mutual labels:  socket, socketio
Springboot im
使用springboot + nettysocketio开发的一个简易卡牌游戏。主要想了解游戏服务端开发流程,基本逻辑等相关知识和长连接。
Stars: ✭ 94 (-15.32%)
Mutual labels:  socket
Kcp
⚡ KCP - A Fast and Reliable ARQ Protocol
Stars: ✭ 10,473 (+9335.14%)
Mutual labels:  socket
Workerman
An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols. PHP>=5.3.
Stars: ✭ 9,617 (+8563.96%)
Mutual labels:  socket
Chat.io
A Real Time Chat Application built using Node.js, Express, Mongoose, Socket.io, Passport, & Redis.
Stars: ✭ 1,325 (+1093.69%)
Mutual labels:  socket
Jupiter
Jupiter是一款性能非常不错的, 轻量级的分布式服务框架
Stars: ✭ 1,372 (+1136.04%)
Mutual labels:  socket
Wslbridge2
Explore various ways to connect Windows Subsystem for Linux with Windows terminal emulators.
Stars: ✭ 93 (-16.22%)
Mutual labels:  socket
Deta cache
缓存cache服务器
Stars: ✭ 106 (-4.5%)
Mutual labels:  socket
Advanced Php
最近打算写一些php一些偏微妙的教程,比如关于多进程、socket等相关,都是自己的一些感悟心得
Stars: ✭ 1,271 (+1045.05%)
Mutual labels:  socket
Tcpraw
Sending packets through TCP
Stars: ✭ 86 (-22.52%)
Mutual labels:  socket
Swiftsocket
The easy way to use sockets on Apple platforms
Stars: ✭ 1,497 (+1248.65%)
Mutual labels:  socket
Socket.io Redux
Redux middleware to emit action via socket.io
Stars: ✭ 103 (-7.21%)
Mutual labels:  socket
Kitura Net
Kitura networking
Stars: ✭ 98 (-11.71%)
Mutual labels:  socket

react-socket-io

Build Status

A react provider for socket.io, http://socket.io/

react-socket-io is compatible with browserify.

Installation

npm install react-socket-io --save-dev

How to use

In app container file:

import React from 'react';
import { Socket } from 'react-socket-io';

const uri = 'http://localhost/test';
const options = { transports: ['websocket'] };

export default class AppContainer extends React.Component {
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <Socket uri={uri} options={options}> 
                { this.props.children }
            </Socket>
        );
    }
}

In other files:

import React from 'react';
import { Event } from 'react-socket-io';

export default class MyComponent extends React.Component {
    constructor(props) {
        super(props);
        this.onMessage = this.onMessage.bind(this);
    }

    onMessage(message) {
        console.log(message);
    }

    render() {
        return (
            <div>
                <h1>My React SocketIO Demo.</h1>
                <Event event='eventName' handler={this.onMessage} />
            </div>
        );
    }
}

Related Props

Socket Component Props

uri

Server socket.io uri you want to connect. If you use namespace, refer to socket.io documentation

options

  • reconnection whether to reconnect automatically (true)

  • reconnectionAttempts (Infinity) before giving up

  • reconnectionDelay how long to initially wait before attempting a new reconnection (1000). Affected by +/- randomizationFactor, for example the default initial delay will be between 500 to 1500ms.

  • reconnectionDelayMax maximum amount of time to wait between reconnections (5000). Each attempt increases the reconnection delay by 2x along with a randomization as above

  • randomizationFactor (0.5), 0 <= randomizationFactor <= 1

  • timeout connection timeout before a connect_error and connect_timeout events are emitted (20000)

  • autoConnect by setting this false, you have to call manager.open whenever you decide it's appropriate

  • transports (Array): a list of transports to try (in order). Defaults to ['polling', 'websocket']. Engine always attempts to connect directly with the first one, provided the feature detection test for it passes.

  • rememberUpgrade (Boolean): defaults to false. If true and if the previous websocket connection to the server succeeded, the connection attempt will bypass the normal upgrade process and will initially try websocket. A connection attempt following a transport error will use the normal upgrade process. It is recommended you turn this on only when using SSL/TLS connections, or if you know that your network does not block websockets.

  • rejectUnauthorized (Boolean): If true, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent. Can be used in Node.js client environment to manually specify certificate information.

Event Component Props

event

The event name you want to listen.

handler

A event handler for that event.

Run Example

The example folder contain a basic socket.io server , run npm run-script example to start server, and then visit localhost:8090.

example

As a contributer.

  1. Clone this project.

    git clone [email protected]:charleslxh/react-socket-io.git
    
  2. Install third party packages

    npm install
    
  3. Run gulp

    gulp
    

    If you don't have gulp command, Install it globally.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].