source: trunk/src/org/expeditee/network/MessageReciever.java@ 309

Last change on this file since 309 was 307, checked in by ra33, 16 years ago

Can navigate with PgUp PgDn Home and End with remote framesets

File size: 1.0 KB
Line 
1package org.expeditee.network;
2
3import java.io.IOException;
4import java.net.DatagramPacket;
5import java.net.DatagramSocket;
6
7import org.expeditee.gui.MessageBay;
8
9public class MessageReciever extends DefaultServer {
10 public final static int OFFSET = 2;
11
12 public MessageReciever(int port) throws IOException {
13 super("MessageReciever", port + OFFSET);
14 }
15
16 public void listenForMessages() throws IOException {
17 byte[] buf = new byte[FrameServer.MAX_PACKET_LENGTH];
18
19 // receive request
20 DatagramPacket packet = new DatagramPacket(buf, buf.length);
21 socket.receive(packet);
22
23 String packetContents = new String(packet.getData(), 0, packet
24 .getLength());
25 String sendersName = FrameShare.getInstance().getPeerName(
26 packet.getPort() + 1, packet.getAddress());
27 /**
28 * If the sender of the message is not on our peer list then use their
29 * IP addy.
30 */
31 if (sendersName == null)
32 sendersName = packet.getAddress().toString();
33
34 packetContents = sendersName + " says: " + packetContents;
35 MessageBay.displayMessage(packetContents);
36 }
37}
Note: See TracBrowser for help on using the repository browser.