Skip to content

Latest commit

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

SimpleChat

Simple React Node Websocket chat server and client

The WebSocket API is an advanced technology that makes it possible to open a two-way interactive communication session between the user's browser and a server. With this API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.

This appliction integrates with redux by passing a thunk to the onmessage recieve function.

constwebSocket=Singleton.getInstance();constreceive=(onMessageCb)=>{webSocket.onmessage=(event)=>onMessageCb(JSON.parse(event.data));};constsend=(type,payload)=>webSocket.send(JSON.stringify({ type, payload }));webSocket.onopen=()=>resolve({ send, receive });webSocket.onclose=()=>{webSocket.close();reject(newError("WebSocket Closed"));}...constmiddleware=[thunkMiddleware.withExtraArgument({ send }),logger];conststore=createStore(rootReducer,initialState,applyMiddleware(...middleware),);receive(store.dispatch);

About

Simple React/Redux Node Websocket chat server and client

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages