go-websocket-sample

command module
v0.0.0-...-0207879 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: Unlicense Imports: 7 Imported by: 0

README

Note - repository archived
==========================

Contents moved to
https://github.com/eliben/code-for-blog/tree/master/2016/go-websocket-sample

go-websocket-sample
===================

To see the sample in action, run:

.. sourcecode:: text

    $ go run <path/to/server.go>

This starts up the server; it immediately reports which port it's listening on
(the port can be changed with the ``-port`` flag).

Then open a browser and visit ``http://localhost:<portnum>`` to see the HTML
page that talks with the server using websockets. The server also spins up
a `net/trace <https://godoc.org/golang.org/x/net/trace>`__ debugging page on
``/debug/requests``.

What the sample does
====================

The JavaScript code powering the served web page records mouse movement events
over the shown box and sends them to the server through a websocket. The server
echoes the data back and this is used to update the text reporting the
coordinates.

Moreover, the server also periodically sends the current time over another
websocket, which the client uses to update the time ticker at the top of the
page.

For more details just check out the source - it's very simple.

License
=======

This code is in the public domain. See the ``LICENSE`` file for more details.

Documentation

Overview

Sample client to test the go websocket server.

Runs some sanity checks against a server, and log.Fatal-s in case of errors.

Eli Bendersky [http://eli.thegreenplace.net] This code is in the public domain.

Server-side part of the Go websocket sample.

Eli Bendersky [http://eli.thegreenplace.net] This code is in the public domain.

Jump to

Keyboard shortcuts

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