-
Notifications
You must be signed in to change notification settings - Fork 688
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ChatApplication class to keep a global socket
- Loading branch information
Showing
4 changed files
with
38 additions
and
22 deletions.
There are no files selected for viewing
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
23 changes: 23 additions & 0 deletions
23
app/src/main/java/com/github/nkzawa/socketio/androidchat/ChatApplication.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.github.nkzawa.socketio.androidchat; | ||
|
||
import android.app.Application; | ||
import io.socket.client.IO; | ||
import io.socket.client.Socket; | ||
|
||
import java.net.URISyntaxException; | ||
|
||
public class ChatApplication extends Application { | ||
|
||
private Socket mSocket; | ||
{ | ||
try { | ||
mSocket = IO.socket(Constants.CHAT_SERVER_URL); | ||
} catch (URISyntaxException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public Socket getSocket() { | ||
return mSocket; | ||
} | ||
} |
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
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
8f66b94
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you show me the code of "http://chat.socket.io", I want to know the way is proccess server when it listen a new message or a new user join to server. thank you!