Skip to content

Commit

Permalink
Merge pull request joewalnes#33 from gautamarora/example-java
Browse files Browse the repository at this point in the history
Adding Java examples
  • Loading branch information
joewalnes committed Jan 7, 2014
2 parents 36b5d32 + c255aa0 commit 27cb89f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/java/Count/Count.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class Count {
public static void main(String[] args) {
for(int i = 1; i <= 10; i++) {
System.out.println(i);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
3 changes: 3 additions & 0 deletions examples/java/Count/count.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
javac Count.java
java Count
14 changes: 14 additions & 0 deletions examples/java/Echo/Echo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.io.*;
public class Echo {
public static void main(String[] args) {
while(true) {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String message = in.readLine();
System.out.println(message);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
3 changes: 3 additions & 0 deletions examples/java/Echo/echo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
javac Echo.java
java Echo
5 changes: 5 additions & 0 deletions examples/java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Running the examples on Mac

1. [download and install](https://github.com/joewalnes/websocketd/wiki/Download-and-install) websocketd and add it to your PATH
2. Echo Server: Run `websocketd --port=8080 --devconsole ./echo.sh` and then go to http://localhost:8080 to interact with it
3. Count Server: Run `websocketd --port=8080 ./count.sh` to start the server, then go to [examples/html](https://github.com/joewalnes/websocketd/tree/master/examples/html) folder and double click **count.html** to open in a browser

0 comments on commit 27cb89f

Please sign in to comment.