Package networking.request

Source Code of networking.request.RequestChat

package networking.request;

import core.GameServer;

import dataAccessLayer.ChatLogDAO;

import java.io.IOException;

import networking.response.ResponseChat;

import utility.DataReader;

/**
*
* @author Xuyuan
*/
public class RequestChat extends GameRequest {

    // Data
    private short type;
    private String message;
    // Responses
    private ResponseChat responseChat;

    public RequestChat() {
        responses.add(responseChat = new ResponseChat());
    }

    @Override
    public void parse() throws IOException {
        type = DataReader.readShort(dataInput);
        message = DataReader.readString(dataInput);
    }

    @Override
    public void doBusiness() throws Exception {
        ChatLogDAO.createMessage(client.getPlayer().getID(), message);

        responseChat.setMessage(message);
        responseChat.setName(client.getPlayer().getUsername());
        responseChat.setType(type);

        GameServer.getInstance().addResponseForAllOnlinePlayers(client.getId(), responseChat);
    }
}
TOP

Related Classes of networking.request.RequestChat

TOP
Copyright © 2018 www.massapi.com. 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.