Мне нужна архитектура для Pusher Реализация сторонних и Java-серверов для общения один-на-один.Java Server Pusher Chat: нужна архитектура для Pusher один-на-один чат на сервере java, а также андроид
ниже - это андроид-код, который отлично работает, и я получаю auth
.
{"event":"pusher:subscribe","data":{"auth":"9272f25541ab7b04fc60:e146b0b663fdfe276af5e4d45de6db7db272bd103414cc9525b998c5eff35268","channel_data":"{\"user_id\":\"12345\",\"user_info\":{\"name\":\"Phil Leggetter\",\"twitterId\":\"@leggetter\"}}","channel":"presence-channel"}}
и Android-код здесь:
final HttpAuthorizer authorizer = new HttpAuthorizer(Constant.BASE_URL_BHARTI + "initial/pusher/auth");
//authorizer.setHeaders(getMapAuthorizationHeaders());
PusherOptions options = new PusherOptions().setAuthorizer(authorizer);
final Pusher pusher = new Pusher("9272f25541ab7b04fc60", options);
pusher.connect(new com.pusher.client.connection.ConnectionEventListener() {
@Override
public void onConnectionStateChange(ConnectionStateChange connectionStateChange) {
Log.e("connectionStateChange", connectionStateChange.getCurrentState().toString());
if (connectionStateChange.getCurrentState() == ConnectionState.CONNECTED) {
SOCKET_ID = pusher.getConnection().getSocketId();
Log.e("SOCKET_ID", "" + SOCKET_ID);
channel = pusher.subscribePresence("presence-channel", new PresenceChannelEventListener() {
@Override
public void onUsersInformationReceived(String channelName, Set<User> users) {
Log.e("PUSHER", "" + channelName + " " + new Gson().toJsonTree(users));
}
@Override
public void userSubscribed(String channelName, User user) {
Log.e("PUSHER", "Channel userSubscribed authorization succeeded " + channelName);
}
@Override
public void userUnsubscribed(String channelName, User user) {
Log.e("PUSHER", "Channel userUnsubscribed authorization err " + channelName);
}
@Override
public void onAuthenticationFailure(String message, Exception e) {
Log.e("PUSHER", "Channel subscription authorization failed " + e);
}
@Override
public void onSubscriptionSucceeded(String channelName) {
Log.e("PUSHER", "Channel subscription authorization succeeded " + channelName);
CHANELNAME = channelName;
}
@Override
public void onEvent(String channelName, String eventName, String data) {
Log.e("PUSHER", "An event with name " + eventName + " was delivered!!" + " " + data + " " + channelName);
Gson gson = new Gson();
Message message = gson.fromJson(data, Message.class);
try {
messageAdapter.add(message);
messagesView.setSelection(messageAdapter.getCount() - 1);
} catch (Exception e) {
Log.e("Exception", "" + e);
}
}
},"my-event");
Теперь мне нужно Java реализации на стороне сервера код для один к одному чата.
thnx bh arti для ответа –
, пожалуйста, объясните подробнее об этом –