Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.io.IOException;
- import java.net.*;
- public class ClientPeer {
- private String sender_name;
- private Socket socket;
- public ClientPeer(String name, Socket sk) throws IOException {
- this.sender_name = name;
- this.socket = sk;
- }
- public void sendMessage(String message) throws IOException {
- Message m1 = new Message(sender_name, message);
- try{
- ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
- out.writeObject(m1);
- }catch(IOException e){
- e.printStackTrace();
- }
- }
- public void close() throws IOException {
- try {
- socket.getOutputStream().close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement