Created
August 6, 2014 09:52
-
-
Save wbspry/8d5fb6c9e5aff03679c1 to your computer and use it in GitHub Desktop.
Playframework付属のサンプル'websocket-chat'を見てみる(1/4) ref: http://qiita.com/yyyske/items/d9e3cf69f7a6f5fb732b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Result chatRoom(String username) { | |
if(username == null || username.trim().equals("")) { | |
flash("error", "Please choose a valid username."); | |
return redirect(routes.Application.index()); | |
} | |
return ok(chatRoom.render(username)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flash("error", "Please choose a valid username."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET /room controllers.Application.chatRoom(username: String ?= null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@main(null) { | |
@if(flash.containsKey("error")) { | |
<div class="alert-message error"> | |
<p> | |
<strong>Oops!</strong> @flash.get("error") | |
</p> | |
</div> | |
} | |
<div class="alert-message block-message info"> | |
<p> | |
<strong>This is the Play Websocket sample application!</strong> | |
To start, choose a username and sign in using the top right form. | |
</p> | |
</div> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@if(connected != null) { | |
<p class="pull-right"> | |
Logged in as @connected — | |
<a href="@routes.Application.index()">Disconnect</a> | |
</p> | |
} else { | |
<form action="@routes.Application.chatRoom()" class="pull-right"> | |
<input id="username" name="username" class="input-small" | |
type="text" placeholder="Username"> | |
<button class="btn" type="submit">Sign in</button> | |
</form> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Routes | |
# This file defines all application routes (Higher priority routes first) | |
# ~~~~ | |
# Home page | |
GET / controllers.Application.index() | |
GET /room controllers.Application.chatRoom(username: String ?= null) | |
GET /room/chat controllers.Application.chat(username) | |
GET /assets/javascripts/chatroom.js controllers.Application.chatRoomJs(username) | |
# Map static resources from the /public folder to the /assets URL path | |
GET /assets/*file controllers.Assets.at(path="/public", file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment