• Stars
    star
    211
  • Rank 186,214 (Top 4 %)
  • Language ActionScript
  • Created over 13 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Library to help Flash, Flex and ActionScript clients connect to Socket.IO servers.

FlashSocket.IO

Flash library to facilitate communication between Flex applications and Socket.IO servers.

The actual websocket communication is taken care of by my fork of gimite/web-socket-js project.

This project wraps that and facilitates the hearbeat and en/decoding of messages so they work with Socket.IO servers

Checkout

Because this project makes use of git submodules you must make use of the recursive clone.

git clone --recursive git://github.com/simb/FlashSocket.IO.git

Building

Because this library is dependent on the websocket library, you must add the support/websocket-js path to you source path in flash builder or your build files.

Usage

For Socket.io 0.7 and 0.8 you will need to use the Beta swc that you can find in the downloads section. Currently in beta.

An example of a flex application connecting to a server on localhost is below

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
			   creationComplete="application1_creationCompleteHandler(event)">
	<s:layout>
		<s:VerticalLayout />
	</s:layout>
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	<fx:Script>
		<![CDATA[
			import com.pnwrain.flashsocket.FlashSocket;
			import com.pnwrain.flashsocket.events.FlashSocketEvent;

			import mx.controls.Alert;
			import mx.events.FlexEvent;

			[Bindable]
			protected var socket:FlashSocket;

			protected function application1_creationCompleteHandler(event:FlexEvent):void
			{

				socket = new FlashSocket("localhost:8080");
				socket.addEventListener(FlashSocketEvent.CONNECT, onConnect);
				socket.addEventListener(FlashSocketEvent.MESSAGE, onMessage);
				socket.addEventListener(FlashSocketEvent.IO_ERROR, onError);
				socket.addEventListener(FlashSocketEvent.SECURITY_ERROR, onError);

				socket.addEventListener("my other event", myCustomMessageHandler);
			}

			protected function myCustomMessageHandler(event:FlashSocketEvent):void{
				Alert.show('we got a custom event!')	
			}

			protected function onConnect(event:FlashSocketEvent):void {

				clearStatus();

			}

			protected function onError(event:FlashSocketEvent):void {

				setStatus("something went wrong");

			}

			protected function setStatus(msg:String):void{

				status.text = msg;

			}
			protected function clearStatus():void{

				status.text = "";
				this.currentState = "";

			}

			protected function onMessage(event:FlashSocketEvent):void{

				trace('we got message: ' + event.data);
				socket.send({msgdata: event.data},"my other event");

			}

		]]>
	</fx:Script>
	<s:Label id="status" />
	<s:Label id="glabel" />
</s:Application>

More Repositories

1

FlexUnit-4-Actionscript-Only-Demo

Simple Application to demo FlexUnit testing and AS3 only project
JavaScript
8
star
2

JasS

Code for my "Put some Javascript in your backend" talk from 360 Flex 2011.
JavaScript
7
star
3

flexrestauth

Simple Flex example of using restful_authentication
JavaScript
6
star
4

FlexInJS

Notes and code related to my Flex to JS talks
JavaScript
4
star
5

pictair_me

Social Network Photo Updater
ActionScript
3
star
6

NodePoll

Flash and Node Live Polling Demo
JavaScript
3
star
7

FlashSocketDemo

Demo using the FlashSocket.IO library project
3
star
8

EasyTimer

Simple Flex Mobile Application
ActionScript
3
star
9

ply

Lightweight MXML Framework
ActionScript
2
star
10

easyMVC

Legacy framework for making it easy to start using the Cairngorm framwork with Flex
ActionScript
2
star
11

Flex4TitleWindowDemo

Demo of extending Flex 4 skins and life cycle
JavaScript
2
star
12

ActionBarless

Example of ViewNavigator Skins using MXML and AS3
ActionScript
2
star
13

As3FXG

A Quick demo using as3 and FXG as statically compiled assets.
ActionScript
2
star
14

NodeJSandYou

JavaScript
2
star
15

gumbodefaultbuttonskin

An example of setting a default skin on a custom component without using css.
ActionScript
2
star
16

myDecembeard

Source code for the myDecembeard.com project
JavaScript
1
star
17

apm

Actionscript Package Manager
JavaScript
1
star
18

SimpleSocketIODemo

Simple implementation of the socket IO demos
JavaScript
1
star
19

GoodPhoto

Simple Demo of CF 9 ORM and AIR offline Syncronization
1
star
20

IconButtonDemo

ActionScript
1
star
21

SimpleNodeMongoose

This is the code I got working from R. Scott Browns example posts here: http://blog.rsbrown.net/2010/10/nodejs-express-jade-and-mongodb-on-mac_10.html
JavaScript
1
star