|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object muthesius.net.WebSocketP5
public class WebSocketP5
/* Simple WebSocketServer Example http://github.com/muthesius/WebSocketP5 */ import muthesius.net.*; import org.webbitserver.*; WebSocketP5 socket; void setup() { socket = new WebSocketP5(this,8080); } void draw() {} void stop(){ socket.stop(); } void mousePressed(){ socket.broadcast("hello from processing!"); } void websocketOnMessage(WebSocketConnection con, String msg){ println(msg); } void websocketOnOpen(WebSocketConnection con){ println("A client joined"); } void websocketOnClosed(WebSocketConnection con){ println("A client left"); }
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_SOCKET
|
static java.lang.String |
VERSION
|
Constructor Summary | |
---|---|
WebSocketP5(processing.core.PApplet theParent)
Initialize a Websocket as a Webbit Webserver with a socket. |
|
WebSocketP5(processing.core.PApplet theParent,
int port)
|
|
WebSocketP5(processing.core.PApplet theParent,
int port,
java.lang.String socketname)
|
Method Summary | |
---|---|
void |
broadcast(java.lang.String msg)
Broadcast a message to all clients |
void |
dispose()
|
int |
getPort()
Return the port of the server. |
java.lang.String |
getUri()
Return the URI of the server. |
int |
howManyConnections()
How many connections do we have? |
void |
onClose(WebSocketConnection conn)
|
void |
onMessage(WebSocketConnection connection,
byte[] message)
|
void |
onMessage(WebSocketConnection conn,
java.lang.String message)
|
void |
onOpen(WebSocketConnection conn)
|
void |
onPong(WebSocketConnection connection,
java.lang.String message)
|
void |
sendAll(java.lang.String msg)
Alias for broadcast |
void |
start()
|
void |
stop()
|
static java.lang.String |
version()
Return the version of the library. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String VERSION
public static final java.lang.String DEFAULT_SOCKET
Constructor Detail |
---|
public WebSocketP5(processing.core.PApplet theParent)
theParent
- port
- The port the socket should be served on (mus be >1024)socketname
- Give the socket a name - this results to the URL in your
javascript, e.g. you give it "mysocket", the URL will be
ws:///* Simple WebSocketServer Example http://github.com/muthesius/WebSocketP5 */ import muthesius.net.*; import org.webbitserver.*; WebSocketP5 socket; void setup() { socket = new WebSocketP5(this,8080); } void draw() {} void stop(){ socket.stop(); } void mousePressed(){ socket.broadcast("hello from processing!"); } void websocketOnMessage(WebSocketConnection con, String msg){ println(msg); } void websocketOnOpen(WebSocketConnection con){ println("A client joined"); } void websocketOnClosed(WebSocketConnection con){ println("A client left"); }
public WebSocketP5(processing.core.PApplet theParent, int port)
public WebSocketP5(processing.core.PApplet theParent, int port, java.lang.String socketname)
Method Detail |
---|
public void start()
public void stop()
public void dispose()
public static java.lang.String version()
public int getPort()
public java.lang.String getUri()
public int howManyConnections()
public void broadcast(java.lang.String msg)
msg
- The message to braodcast to all connected clientspublic void sendAll(java.lang.String msg)
public void onOpen(WebSocketConnection conn)
public void onClose(WebSocketConnection conn)
public void onMessage(WebSocketConnection conn, java.lang.String message)
public void onMessage(WebSocketConnection connection, byte[] message)
public void onPong(WebSocketConnection connection, java.lang.String message)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |