mWebSocket aims to implement the client portion of the WebSocket Standard in mSL for mIRC and AdiIRC. It is not, however, a fully featured HTTP client and as such will not follow HTTP redirects or process non-websocket related responses.
If you appreciate the work done, consider donating via paypal @ StreamJar
You may do with the code as you wish so long as you do not redistrubute any files contained with in this repository, in part or whole, without direct permission from me. You may directly link to any asset within this repository so long as you also include a link to the top level of the repository.
SReject © 2016; All rights reserved.
mIRC v7.4x or AdiIRC v2.2
- Download the latest release or
mWebSocket-vx.x.xxxx-yyyy.mrc
from the /builds/ directory - In mIRC/AdiIRC, enter the following command in an editbox:
//load -rs $$sfile($mircdir, Load, Open)
- Navigate to and select the downloaded file
- Click "Open"
Creates a WebSocket handler.
Switches
None
Parameters
name
- required
The name to reference the handler by. Must be not be an interger or start with-
uri
- required
The uri to connect to. Usewss://
as the uri scheme for an SSL connection
timeout
- optional
The time, in seconds, to wait for the connection to be established before timing out the connection
Stores the specified item-data pair.
Use$WebSockMark
to access stored data.
Switches
-n
The value is to be interpreted as plain text
-r
The specified item is to be removed
Parameters
name
- required
The name to reference the handler by. Must be not be an interger or start with-
item
- required
The name to be used to reference the specified data
text|&bvar
- requied unless -r switch is used
The data to be stored.
Sends the specified frame through a WebSocket.
Can only be used after the HANDSHAKE has completed.
Switches
-c
The data should be sent as a CLOSE frame
-p
The data should be sent as a PING frame
-P
The data should be sent as a PONG frame
-b
The data should be sent as a BINARY frame
-t
The data should be sent as a TEXT frame (default)
+t
The passed data is to be treated as plain-text
+w
The specifiedname
is a wildcard. The frame will be added to all matching and applicable web sockets.
Parameters
name
- required
The WebSocket name.
text|&bvar
- required
The data to be included with the frame
Stores the specified header to be used with the HTTP request.
Can only be used from theINIT
event
Switches
None
Parameters
header
- required
The header name to set
value
- required
The value for the header
Sends a CLOSE control-frame to the server
Switches
-f
If specified the socket will be immediately closed
-w
The specifiedname
parameter is a wildcard. All applicable websockets will be closed
-e[code]
The specified status code will be sent with the close frame; otherwise 1000 is used
Parameters
name
- required
The WebSocket to close
data
- optional Text data to send with the close frame
Lists all open WebSockets
If used from within a WebSocket event, the WebSocket name is returned
Returns the websocket name if it exists
Parameters
name
- required
The name of the WebSocket instance
n
- optional if specified,name
is assumed to be a wildcard and data related to the nth matching websock is returned
Properties
State
Returns the current websocket state
StateText
Returns the text equivulant of the websocket state
Ssl
Returns$true
if the connection is Ssl
Host
Returns the host for the connection
Port
Returns the port connected to
Uri
Returns the URI used to connect to
HttpVersion
Returns the HTTP version of the connection
Only applicatable after the HTTP response has been received
StatusCode
Returns the HTTP statuscode returned by the server
Only applicatable after the HTTP response has been received
StatusText
Returns the HTTP Status Text returned by the server
Only applicatable after the HTTP response has been received
Returns the specified header.
Only applictable after the HTTP response has been received
Parameters
name
- Required
The name of the WebSocket instance
header
- Optional
The name of the header to look up
If specified, the nth header of the specified name is returned
Ifn
is0
the total number of matching headers is returned
n
- Required
Returns the nth header.
if a[header]
name is not specified, the nth header name is returned
if0
the total number of headers is returned
Returns stored data associated with the specified item
Parameters
name
- Required
The name of the WebSocket instance
item|n
- Optional
The item to return data for
Ifitem
is an integer the nth stored item name is returned
ifitem
is 0, the total number of items stored is returned
Properties
item
If specified, the inputitem
is treated as a iteral name even if numerical
Returns the received frames data as utf8 text Only applicable from within the
CLOSING
andDATA
events
Returns various information about the recieved frame
Parameters
Type
- literal
if the literal textType
is specified, the frame type numerical value is returned
TypeText
- literal
If the literal textTypeText
is specified, the frame's type text representation is returned
&bvar
if a valid bvar is specified, the frame data will be copied into the specified bvar overwriting any data it previously contained
Returns the WebSocket error
Only applicatable from within theERROR
event
Returns the WebSocket error message
Only applicatable from within theERROR
event
Al events are raised as a signal event formated as:
WebSocket_[EVENT]_[name]
[EVENT]
The event name
[name]
The websocket name from which the event originated
Raised when the socket connection has been established.
$WebSock
can be used to retrieve the WebSock name
/WebSockHeader
can be used from within this event to set request headers
Raise when the HTTP request has been sent and a server response is pending
$WebSock
can be used to retrieve the WebSock name
Raised when the HTTP handshake has successfully completed and the WebSocket is ready to send/recieve data
$WebSock
can be used to retrieve the WebSock name
Raised when a DATA, PING or PONG frame has been recieved.
$WebSock
can be used to retrieve the WebSock name
$WebSockType
,$WebSockTypeText
,$WebSockText
and$WebSockData
can be used to reference the received dataThe script will automatically respond to WebSocket PING frames
Raised when a CLOSE frame has been recieved
$WebSock
can be used to retrieve the WebSock name
$WebSockType
,$WebSockTypeText
,$WebSockText
and$WebSockData
can be used to reference the recieved data
Raised when the remote host has closed the connection.
The websocket will be destroyed after this event.A new websocket can not be created from this event reusing the name.
Raised when an error occured durring socket communications.
The websocket will be destroyed after this event.
$WebSockErr
and$WebSockErrMsg
can be used to access information about the errorA new websocket can not be created from this event reusing the name.
Raised after a websocket has been destroyed
A new websocket CAN be created from this event reusing the name
User | Reason |
---|---|
ACPixel | Giving me the idea |
Membear | Providing help with the protocol |
Ouims | Various code improvement suggestions |
Saturn | Suggesting the use of $longip() to convert to 16/32bit uints |