Package voxo.common.entities

Examples of voxo.common.entities.Packet


  public ClientSearchRequestAction(InetAddress ip, String o) throws UnknownHostException, IOException, SQLException {
    // Get the search results
    ArrayList<User> alu = UserManager.searchByUsername(o);
   
    // Send results
    NetworkService.sendPacket(ip, new Packet(EnumPacket.SERVER_SearchResults, alu));
  }
View Full Code Here


public class SendContactListAction {
  public SendContactListAction(User u) throws UnknownHostException, IOException, SQLException {
    if (u.getOnline() && (u.getIp() != null)) {
      ContactListPacket clp = new ContactListPacket(UserManager.getUserContactsByUser(u), UserManager.getUserContactRequestsByUser(u));
      NetworkService.sendPacket(u.getIp(), new Packet(EnumPacket.SERVER_UpdateContact, clp));
    }
  }
View Full Code Here

    // Update contact list to his online members
    ArrayList<User> alcu = UserManager.getUserContactsByUser(u);
    for (User iU : alcu) {
      if (iU.getOnline() && (iU.getIp() != null)) {
        new SendContactListAction(iU);
        NetworkService.sendPacket(iU.getIp(), new Packet(EnumPacket.SERVER_Notice, String.format(Messages.getString("UserLogoutAction.UserDisconnect"), u.getUsername()))); //$NON-NLS-1$
      }
    }
  }
View Full Code Here

import voxo.server.managers.UserManager;
import voxo.server.services.NetworkService;

public class KickUserAction {
  public KickUserAction(User u) throws UnknownHostException, IOException, SQLException {
    NetworkService.sendPacket(u.getIp(), new Packet(EnumPacket.SERVER_KickUser, null));
  }
View Full Code Here

    }
    if (from == null) {
      throw new RequestException(Messages.getString("ContactAddAction.ERR_UserNotFound")); //$NON-NLS-1$
    }
    MailService.sendMail(from.getEmail(), from.getUsername(), to.getEmail(), to.getUsername(), String.format(Messages.getString("SendEmailAction.MailSubject"), from.getUsername()), String.format(Messages.getString("SendEmailAction.MailBody"), cp.getTxtMsg())); //$NON-NLS-1$ //$NON-NLS-2$
    NetworkService.sendPacket(ip, new Packet(EnumPacket.SERVER_Notice, Messages.getString("SendEmailAction.MailSentResponce"))); //$NON-NLS-1$
  }
View Full Code Here

  public SendMessageAction(String m, User u, EnumPacket ep) throws UnknownHostException, IOException {
    if (u.getOnline() && (u.getIp() != null)) {
      if ((ep != EnumPacket.SERVER_Notice) && (ep != EnumPacket.SERVER_Error)) {
        return;
      }
      NetworkService.sendPacket(u.getIp(), new Packet(ep, m));
    }
  }
View Full Code Here

public class UserLoginAction {
  public UserLoginAction(InetAddress ip, LoginPacket lp) throws SQLException, UnknownHostException, IOException, RequestException {
    // Check Login
    ArrayList<User> alu = UserManager.searchUserAbsolute(new User(null, lp.getUsername(), lp.getPwd(), null, null, null, null));
    if (alu.size() != 1) {
      NetworkService.sendPacket(ip, new Packet(EnumPacket.SERVER_Error, Messages.getString("UserLoginAction.UsernamePasswordInvalid"))); // Send notice //$NON-NLS-1$
      throw new RequestException(Messages.getString("UserLoginAction.ERR_WrongUsername")); //$NON-NLS-1$
    }

    // Get the user
    User u = alu.get(0);

    // Check if already logged
    if (u.getOnline()) {
      NetworkService.sendPacket(u.getIp(), new Packet(EnumPacket.SERVER_Error, Messages.getString("UserLoginAction.ERR_DualLoginKick"))); //$NON-NLS-1$
      new KickUserAction(u);
      throw new RequestException(Messages.getString("UserLoginAction.ERR_DualLogin"));
    }
   
    // Set online
    u.setOnline(true);
    u.setIp(ip.getHostAddress());
    UserManager.updateUserById(u);


    // Send updates to the client
    NetworkService.sendPacket(ip, new Packet(EnumPacket.SERVER_LoginAccepted, u)); // Send
                                            // responce
    new SendContactListAction(u); // Send contacts
    NetworkService.sendPacket(ip, new Packet(EnumPacket.SERVER_Notice, Messages.getString("UserLoginAction.WelcomeMsg"))); // Send notice //$NON-NLS-1$

    // Update contact list to his online members
    ArrayList<User> alcu = UserManager.getUserContactsByUser(u);
    for (User iU : alcu) {
      if (iU.getOnline() && (iU.getIp() != null)) {
        new SendContactListAction(iU);
        NetworkService.sendPacket(iU.getIp(), new Packet(EnumPacket.SERVER_Notice, String.format(Messages.getString("UserLoginAction.UserConnect"), u.getUsername()))); //$NON-NLS-1$
      }
    }
  }
View Full Code Here

import voxo.common.enums.EnumPacket;
import voxo.server.services.NetworkService;

public class SendHeartBeat {
  public SendHeartBeat(String ip) throws UnknownHostException, IOException {
    NetworkService.sendPacket(ip, new Packet(EnumPacket.SERVER_HeartBeat, null));
  }
View Full Code Here

         
          sock = srvSock.accept();
          in = sock.getInputStream();
          oin = new ObjectInputStream(in);

          Packet p = (Packet) oin.readObject(); // Get the packet

          new PacketParser(sock.getInetAddress(), p).start();
        } catch (SocketTimeoutException e) {
        } catch (IOException | ClassNotFoundException e) {
          this.c.getVerbose().addConsoleMsg(e, EnumSet.of(EnumVerbose.ToConsole, EnumVerbose.ToLog));
View Full Code Here

import voxo.common.packets.ChatPacket;

public class SendMailAction {
  public SendMailAction(ClientController c, ChatPacket p){
    try {
      NetworkService.sendPacket(new Packet(EnumPacket.CLIENT_SendEmail, p));
    } catch (UnknownHostException e) {
      c.getVerbose().addConsoleMsg(e, EnumSet.of(EnumVerbose.ToConsole, EnumVerbose.ToLog));
      new ServerErrorAction(c);
    } catch (IOException e) {
      c.getVerbose().addConsoleMsg(e, EnumSet.of(EnumVerbose.ToConsole, EnumVerbose.ToLog));
View Full Code Here

TOP

Related Classes of voxo.common.entities.Packet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.