AS3WebSocket

ActionScript 3 WebSocket client implementation for the final WebSocket Draft RFC6455

  • 所有者: theturtle32/AS3WebSocket
  • 平台:
  • 許可證: Apache License 2.0
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

ActionScript 3 WebSocket Client

This is an AS3 implementation of a client library of the WebSocket protocol, as specified in the RFC6455 standard.

Explanation

THIS CLIENT WILL NOT WORK with draft-75 or draft-76/-00 servers that are deployed on the internet. It is only for the most recent RFC6455 standard. I will keep a version tracking each of the IETF drafts in its own branch, with master tracking the latest.

I intend to keep this library updated to the latest draft of the IETF WebSocket protocol when new versions are released. I built this library because I wanted to be able to make use of the latest draft of the protocol, but no browser implements it yet.

See the WebSocket Protocol Specification (RFC6455).

The AS3WebSocket directory contains a Flash Builder 4.6 Library Project that contains the WebSocket client library.

The testApp directory contains a Flash Builder 4.6 Air Project that uses the AS3WebSocket library and implements two of the test subprotocols from Andy Green's libwebsockets test server, the dumb-increment-protocol, and the lws-mirror-protocol. Click here for more detail about the libwebsockets test server.

License

This library is released under the Apache License, Version 2.0.

Download

  • The Adobe Air test application and the client library in SWC format are both available under the "Downloads" section above.

Features

  • Based on the RFC6455 standard WebSocket protocol
  • wss:// TLS support w/ hurlant as3crypto library
  • Can send and receive fragmented messages
  • Test Adobe Air app implements two of the subprotocols supported by Andy Green's libwebsockets-test-server:
    • dumb-increment-protocol (simple streaming incrementing numbers)
    • lws-mirror-protocol (shared drawing canvas)
    • Added fraggle-protocol to the list, but I'm having difficulty testing as there seems to be a problem with the libwebsockets-test-fraggle server (its own client complains of corrupt data intermittently when I run it on my machine)

Known Issues:

  • There is no user-provided extension API implemented
  • Only the libwebsocket-test-server subprotocols mentioned have been tested so far

Usage Example

var websocket:WebSocket = new WebSocket("wss://localhost:4321/foo?bing=baz", "*", "my-chat-protocol");
websocket.enableDeflateStream = true;
websocket.addEventListener(WebSocketEvent.CLOSED, handleWebSocketClosed);
websocket.addEventListener(WebSocketEvent.OPEN, handleWebSocketOpen);
websocket.addEventListener(WebSocketEvent.MESSAGE, handleWebSocketMessage);
websocket.addEventListener(WebSocketErrorEvent.CONNECTION_FAIL, handleConnectionFail);
websocket.connect();

function handleWebSocketOpen(event:WebSocketEvent):void {
  trace("Connected");
  websocket.sendUTF("Hello World!\n");
  
  var binaryData:ByteArray = new ByteArray();
  binaryData.writeUTF("Hello as Binary Message!");
  websocket.sendBytes(binaryData);
}

function handleWebSocketClosed(event:WebSocketEvent):void {
  trace("Disconnected");
}

private function handleConnectionFail(event:WebSocketErrorEvent):void {
  trace("Connection Failure: " + event.text);
}

function handleWebSocketMessage(event:WebSocketEvent):void {
  if (event.message.type === WebSocketMessage.TYPE_UTF8) {
    trace("Got message: " + event.message.utf8Data);
  }
  else if (event.message.type === WebSocketMessage.TYPE_BINARY) {
    trace("Got binary message of length " + event.message.binaryData.length);
  }
}

概覽

名稱與所有者theturtle32/AS3WebSocket
主編程語言ActionScript
編程語言ActionScript (語言數: 2)
平台
許可證Apache License 2.0
發布數0
創建於2011-03-27 22:20:04
推送於2016-09-22 20:13:57
最后一次提交2014-06-19 18:10:56
星數245
關注者數39
派生數96
提交數102
已啟用問題?
問題數28
打開的問題數7
拉請求數5
打開的拉請求數1
關閉的拉請求數0
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?
去到頂部