Skip to content

Instantly share code, notes, and snippets.

View odadoda's full-sized avatar

Øyvind Dahl odadoda

View GitHub Profile
@odadoda
odadoda / Application.java:index()
Created November 8, 2013 13:14
Render index.html
// render index page
public static Result index() {
return ok(index.render());
}
@odadoda
odadoda / Application.java:wsJs()
Created November 8, 2013 13:15
Render the javascript file
// get the ws.js script
public static Result wsJs() {
return ok(views.js.ws.render());
}
@odadoda
odadoda / Application.java:wsInterface()
Created November 8, 2013 13:16
Return a websocket connection
// Websocket interface
public static WebSocket<String> wsInterface(){
return new WebSocket<String>(){
// called when websocket handshake is done
public void onReady(WebSocket.In<String> in, WebSocket.Out<String> out){
SimpleChat.start(in, out);
}
};
}
@odadoda
odadoda / SimpleClass.java
Created November 8, 2013 13:21
Taking care of websockets and in and out messages
package models;
import play.mvc.*;
import play.libs.*;
import play.libs.F.*;
import java.util.*;
public class SimpleChat{
@odadoda
odadoda / ws.js
Created November 8, 2013 13:23
Clientside
$(function(){
// get websocket class, firefox has a different way to get it
var WS = window['MozWebSocket'] ? window['MozWebSocket'] : WebSocket;
// open pewpew with websocket
var socket = new WS('@routes.Application.wsInterface().webSocketURL(request)');
var writeMessages = function(event){
$('#socket-messages').prepend('<p>'+event.data+'</p>');
@odadoda
odadoda / routes
Created November 22, 2013 07:10
How the simplechat "routes" file routes the incoming requests
GET / controllers.Application.index()
GET /assets.javascript.ws.js controllers.Application.wsJs()
GET /wsInterface controllers.Application.wsInterface()
@odadoda
odadoda / ls-bin
Created February 28, 2014 11:24
list commands in /bin
ls /bin
@odadoda
odadoda / ls-bin
Created February 28, 2014 11:27
write out content for global variable "path"
echo $PATH
@odadoda
odadoda / content-of-path
Created February 28, 2014 11:28
Content of global variable "path"
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
@odadoda
odadoda / direcotires-with-commands
Created February 28, 2014 11:29
Directories to find commands
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin