Movatterモバイル変換


[0]ホーム

URL:


wsjs

package
v1.8.13Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License:ISCImports:1Imported by:0

Details

Repository

github.com/coder/websocket

Links

Documentation

Rendered for js/wasm

Overview

Package wsjs implements typed access to the browser javascript WebSocket API.

https://developer.mozilla.org/en-US/docs/Web/API/WebSocket

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeCloseEvent

type CloseEvent struct {Codeuint16ReasonstringWasCleanbool}

CloseEvent is the type passed to a WebSocket close handler.

typeMessageEvent

type MessageEvent struct {// string or []byte.Data interface{}}

MessageEvent is the type passed to a message handler.

typeWebSocket

type WebSocket struct {// contains filtered or unexported fields}

WebSocket is a wrapper around a javascript WebSocket object.

funcNew

func New(urlstring, protocols []string) (cWebSocket, errerror)

New is a wrapper around the javascript WebSocket constructor.

func (WebSocket)Close

func (cWebSocket) Close(codeint, reasonstring) (errerror)

Close closes the WebSocket with the given code and reason.

func (WebSocket)OnClose

func (cWebSocket) OnClose(fn func(CloseEvent)) (remove func())

OnClose registers a function to be called when the WebSocket is closed.

func (WebSocket)OnError

func (cWebSocket) OnError(fn func(ejs.Value)) (remove func())

OnError registers a function to be called when there is an errorwith the WebSocket.

func (WebSocket)OnMessage

func (cWebSocket) OnMessage(fn func(mMessageEvent)) (remove func())

OnMessage registers a function to be called when the WebSocket receives a message.

func (WebSocket)OnOpen

func (cWebSocket) OnOpen(fn func(ejs.Value)) (remove func())

OnOpen registers a function to be called when the WebSocket is opened.

func (WebSocket)SendBytes

func (cWebSocket) SendBytes(v []byte) (errerror)

SendBytes sends the given message as a binary messageon the WebSocket.

func (WebSocket)SendText

func (cWebSocket) SendText(vstring) (errerror)

SendText sends the given string as a text messageon the WebSocket.

func (WebSocket)Subprotocol

func (cWebSocket) Subprotocol()string

Subprotocol returns the WebSocket subprotocol in use.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp