go-chat

command module
v0.0.0-...-112379a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 3 Imported by: 0

README

go-chat

Practice chat web app with Golang and Websocket

Websocket methods

  1. WebSocket(): Make an instance of the websocket
const socket = new WebSocket('ws://localhost:8000')
  1. WebSocket.send(): Send a message to the server
socket.send('Hello, server!')
  1. WebSocket.onopen: This event is triggered when the WebSocket connection is successfully opened.
socket.onopen = (event) => {
  console.log('WebSocket connection opened!');
};
  1. WebSocket.onmessage: This event is triggered when a message is received from the server.
socket.onmessage = (event) => {
  console.log('Received message from server: ', event.data);
};
  1. WebSocket.onclose: Triggered when the WebSocket is closed.
socket.onclose = (event) => {
  console.log('WebSocket connection closed!');
};
  1. WebSocket.onerror: This event is triggered when a WebSocket error occurs.
socket.onerror = (event) => {
  console.error('WebSocket error: ', event);
};

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL