Skip to content

SaulDoesCode/CraftSocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

CraftSocket

small wrapper around JavaScript's WebSocket API

Using CraftSocket

Make a new CraftSocket Object
  var socket = new CraftSocket("ws://" + location.hostname + ":" + port + "/");
  // The CraftSocket Object takes any ws:// or wss:// address 
Send the Server a message
 socket.send('Hello GoGo', res => console.log(res));
 // First argument is the message you want to send   
 // Second argument is a callback function with the server response as a parameter
Recieve a message from the Server
 socket.recieve(msg => console.log(msg));
 // every time the server sends a message, 
 // the callback function will fire with the server's response as a parameter

About

small wrapper around JavaScript's WebSocket API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published