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.mrcfrom 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$WebSockMarkto 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 specifiednameis 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 theINITevent
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 specifiednameparameter 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,nameis 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$trueif 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
Ifnis0the 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
if0the 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
Ifitemis an integer the nth stored item name is returned
ifitemis 0, the total number of items stored is returned
Properties
item
If specified, the inputitemis treated as a iteral name even if numerical
Returns the received frames data as utf8 text Only applicable from within the
CLOSINGandDATAevents
Returns various information about the recieved frame
Parameters
Type- literal
if the literal textTypeis specified, the frame type numerical value is returned
TypeText- literal
If the literal textTypeTextis 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 theERRORevent
Returns the WebSocket error message
Only applicatable from within theERRORevent
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.
$WebSockcan be used to retrieve the WebSock name
/WebSockHeadercan be used from within this event to set request headers
Raise when the HTTP request has been sent and a server response is pending
$WebSockcan be used to retrieve the WebSock name
Raised when the HTTP handshake has successfully completed and the WebSocket is ready to send/recieve data
$WebSockcan be used to retrieve the WebSock name
Raised when a DATA, PING or PONG frame has been recieved.
$WebSockcan be used to retrieve the WebSock name
$WebSockType,$WebSockTypeText,$WebSockTextand$WebSockDatacan be used to reference the received dataThe script will automatically respond to WebSocket PING frames
Raised when a CLOSE frame has been recieved
$WebSockcan be used to retrieve the WebSock name
$WebSockType,$WebSockTypeText,$WebSockTextand$WebSockDatacan 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.
$WebSockErrand$WebSockErrMsgcan 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 |