Android Open Source - android_smsoverxmpp Server






From Project

Back to project page android_smsoverxmpp.

License

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.

Java Source Code

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;
  }

}




Java Source Code List

com.smorra.smsoverxmpp.BootReceiver.java
com.smorra.smsoverxmpp.Client.java
com.smorra.smsoverxmpp.Contact.java
com.smorra.smsoverxmpp.IpReceiver.java
com.smorra.smsoverxmpp.MainActivity.java
com.smorra.smsoverxmpp.PhoneNumber.java
com.smorra.smsoverxmpp.Server.java
com.smorra.smsoverxmpp.Service_.java
com.smorra.smsoverxmpp.SmsReceiver.java
com.smorra.smsoverxmpp.Util.java