KryoNet - Sending packets to Android clients - java

I am developing an Android app which has to connect clients to my server for sending/receiving different sort of packets. To achieve that, I am using the KryoNet library. My clients connect themself to the server and send their own packets successfully. But my problem is that the server seems to failed at responding to them. I have registered these packets in the same order on the server side and the client side and I use the connection parameter of the overrided reveived method from kryonet.Listener to respond (e.g. connection.sendUDP(...)). I have an Android 5.0.2, I use the 2.22.0-RC1 version of KryoNet both on the server side and the client side... With the option Log.set(Log.LEVEL_DEBUG) enabled, I can see that the server starts to write a packet
(DEBUG: [kryo] write: PacketMovement) but I receive nothing.
I would really appreciate any help on this issue.

The answer for people having the same problem : https://github.com/EsotericSoftware/kryonet/pull/111.

Related

P2P communication , chat App (android)

i am using this tutorial as guide. i am creating an android app which is basically chat application. this uses socket programming to communicate .
i want to connect directly to device and deliver the message. the message does not go to server. server only tell me the address of the device thats it.
i followed the tutorial i mentioned above and this only works for the case where client and server are within same wifi/network. i want to connect to server from client irrespective of their network connection place. how do i do it from any network to any network.
i think i need to use port forwarding , but this is not practical . so we better use a server for keeping track of all the ip changes. and deliver the messages directly from the source to client. so how do i do it. please suggest any resources.
update
as of now what i studied is i have to use innetaddress to communicate if i am inside an wifi router.
thank you

Need to migrate from Java socket to Xmpp communication of my chat application

Need to migrate from Java socket to Xmpp communication of my desktop chat application.
I got a api called SMACK for that but for that I have to use Openfire server i.e I can only code in my client. But I have my own socket server which I am using for my current chat application. Is there a way to use that server and write XMPP specific code in server?? basically reuse the socket server..?
I have written the code using SMACK which calls the server but how to make the server listen to that?
You would have to make your server understand and respond to the XMPP protocol. In other words, you would have to write an XMPP server, which makes no sense when you can simply use one of many existing ones. Using smack doesn't require you to use Openfire, but it is one of many options available.

Client to specific client communication through a server

I have successfully implemented a server -client application where i have maintained a list of clients connected to the server in an array.What i do not understand is how will the client tell the server about the client the message is sent for .Like if server A has 3 clients connected lets say a,b and c.Now if a wants to send a message to c how will it tell the server about it?
i want the client to send a request to server asking to connect to client c ,the server asks client c for permission and if c accepts a and c can send messages back and forth until one of them disconnects
For IM (Instant Messaging), you can look at XMPP Servers and clients, which are very popular in chat application, even gtalk works on them.
XMPP Server : jabber server.
The common practice is exchanging all the messages (in a given protocol) through a server and which intermediates everything. If you want direct communication between the clients, take a look at p2p or peer-to-peer (http://en.wikipedia.org/wiki/Peer-to-peer).
Your question is very similar to this one: Client-Server-Client communication using Sockets

Client Server Apps+java

I have a java requirment contains both client and server side program.
Server side
Server program frequently check the data base and checks if a new order came, if order came it check the order and send it to the corresponding client machine using IP address and port.The client machines are out side the LAV and has static IP address.
Client side
Client program listen a its on port , when an order came, read it and process.
For implementing these app, which java package is best,java socket communication or any other.Anybody know please suggest one.
Help is highly appreciated,
Thanks,
vks.
Don't go for low level programming like Sockets etc. Use RMI. Your program will have following two entities
Server side :
An RMI Client for calling client machine to send update after checking the database
Client side :
An RMI server application listening for Server update requests and do processing.
If you are new to RMI check out this tutorial . You can search for better tutorials if don't find these good enough :).
I remember I had to do something similar in the university and I used JMS (Java Messaging Service), documented here:
http://www.oracle.com/technetwork/java/jms/index.html
The Server will create the messages from the DB by checking it periodically and will send messages to the clients which will process the info.

Network discovery in Java using multicasting

I'm trying to make a client/server Java App. Both client and server will be running on the same wi-fi network. Server will be running on a specific port that client is aware of.
I am planning to send a multicast message from client through the network for that specific port to discover the server. However, I'm not too sure how I can find out which IP in my network received my message.
Do I need to create a socket on the client and listen to incoming packets once I send my multicast message in case server replies back?
Thanks in advance.
(1)server listens on a pre-arranged port
DatagramSocket s = new DatagramSocket(8888);
s.receive //(1)
s.send //(2)
(3)client sends a message to the port, on the broadcast IP, 255.255.255.255
DatagramSocket c = new DatagramSocket();
c.send(255.255.255.255:8888,msg) //(3)
c.receive //(4)
the client binds to a port too. we didn't specify it, so it's random chosen for us.
(3) will broadcast the message to all local machines, server at (1) receives message, with the client IP:port.
(2) server sends response message to client IP:port
(4) client gets the reponse message from server.
I would strongly recommend using JGroups. It has a lot of features and it will do all the UDP stuff. JBoss uses it for their clustering.
You can try using java.net.MulticastSocket (available since Java 1.1). If you don't need the rich feature sets of libs like jgroups, hazelcast etc. that plain Java API might serve you well enough.
See also example pages here and here.
You could try using SSDP. It's what UPnP devices use to discover each other. It's multicast on port 1900 and just uses really simple packets to send around IPs and service information.
Cling is a UPnP lib you can pull from. Note I'm not recommending you move to UPnP - just the discovery protocol used.

Categories

Resources