1 package com.maverick.multiplex.channels; 2 3 import java.io.IOException ; 4 5 import org.apache.commons.logging.Log; 6 import org.apache.commons.logging.LogFactory; 7 8 import com.maverick.multiplex.Channel; 9 import com.maverick.multiplex.ChannelOpenException; 10 import com.maverick.util.ByteArrayWriter; 11 12 public class StreamClientChannel extends Channel { 13 final static Log log = LogFactory.getLog(StreamClientChannel.class); 14 15 18 public static final String CHANNEL_TYPE = "stream@3sp.com"; 19 20 String id; 21 boolean initiator; 22 23 29 public StreamClientChannel(String id, boolean initiator) { 30 this(id, initiator, CHANNEL_TYPE); 31 } 32 33 public StreamClientChannel(String id, boolean initiator, String channelType) { 34 super(channelType, 32768, 32768); 35 this.id = id; 36 this.initiator = initiator; 37 } 38 39 44 public String getId() { 45 return id; 46 } 47 48 53 public byte[] open(byte[] data) throws IOException , ChannelOpenException { 54 return null; 55 } 56 57 62 public void onChannelData(byte[] buf, int off, int len) { 63 } 64 65 70 public byte[] create() throws IOException { 71 ByteArrayWriter baw = new ByteArrayWriter(); 72 baw.writeBoolean(initiator); 73 baw.writeString(id); 74 return baw.toByteArray(); 75 } 76 77 82 public void onChannelClose() { 83 } 84 85 public boolean isInitiator() { 86 return initiator; 87 } 88 89 public void onChannelOpen(byte[] data) { 90 } 91 } 92 | Popular Tags |