Back to project page android_smsoverxmpp.
The source code is released under:
GNU General Public License
If you think the Android project android_smsoverxmpp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.smorra.smsoverxmpp; /*from w w w . j av a 2 s.c om*/ import java.io.IOException; import java.util.ArrayList; import android.content.Context; import com.smorra.asyncsocket.TcpServer; import com.smorra.asyncsocket.TcpServerCallback; import com.smorra.asyncsocket.TcpServerClient; public class Server implements TcpServerCallback { TcpServer server; ArrayList<Client> clients = new ArrayList<Client>(); Context context; public Server(Context context) throws IOException { System.out.println("CREATING TCPSERVER"); this.context = context; server = new TcpServer(5222, this); } @Override public void onNewClient(TcpServer ts, TcpServerClient tsc) { System.out.println("NEW CLIENT!"); try { Client c = new Client(tsc, this, context); clients.add(c); } catch (Exception e) { e.printStackTrace(); } } public void close() throws IOException { server.close(); for (Client c : clients) c.close(); } public void removeClient(Client client) { clients.remove(client); } public boolean onSmsReceived() throws IOException { boolean ret = false; for (Client c : clients) { if (c.onSmsReceived()) ret = true; } return ret; } }