首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 互联网 >

Red5 Client 联接 Red5Server

2012-07-22 
Red5 Client 连接 Red5Serverimport java.util.ArrayListimport java.util.Mapimport org.red5.io.utils

Red5 Client 连接 Red5Server

import java.util.ArrayList;import java.util.Map;import org.red5.io.utils.ObjectMap;import org.red5.server.api.event.IEvent;import org.red5.server.api.event.IEventDispatcher;import org.red5.server.api.service.IPendingServiceCall;import org.red5.server.api.service.IPendingServiceCallback;import org.red5.server.net.rtmp.INetStreamEventHandler;import org.red5.server.net.rtmp.RTMPClient;import org.red5.server.net.rtmp.RTMPConnection;import org.red5.server.net.rtmp.codec.RTMP;import org.red5.server.net.rtmp.event.Notify;public class RtmpClientNew extends RTMPClient implements  INetStreamEventHandler, IPendingServiceCallback, IEventDispatcher { String host = "111.92.237.33"; String app = "chainGunSyncService"; int port = 1935; public RtmpClientNew() {  super();  Map<String, Object> map = makeDefaultConnectionParams(host,    1935, "chainGunSyncService");  connect(host, 1935, map, this, new String[] { "admin", "",    "111.92.237.33" }); } @Override public void dispatchEvent(IEvent arg0) {  // TODO Auto-generated method stub } @Override public void resultReceived(IPendingServiceCall call) {  // TODO Auto-generated method stub  Object result = call.getResult();  if (result instanceof ObjectMap) {   if ("connect".equals(call.getServiceMethodName())) {    createStream(this);   }  } else {   if ("createStream".equals(call.getServiceMethodName())) {    if (result instanceof Integer) {     Integer streamIdInt = (Integer) result;     // int streamId = streamIdInt.intValue();     // publish(streamId, "testgio2", "live", this);     invoke("getRoomsInfo", this);    } else {     disconnect();    }   } else if ("getRoomsInfo".equals(call.getServiceMethodName())) {    ArrayList<String> list = (ArrayList<String>) result;    for (int i = 0; i < list.size(); i++) {     System.out.println(list.get(i));    }   }  } } @Override public void onStreamEvent(Notify arg0) {  // TODO Auto-generated method stub } @Override public void connectionOpened(RTMPConnection conn, RTMP state) {  // TODO Auto-generated method stub  // System.out.println("connectionOpened");  super.connectionOpened(conn, state); } public static void main(String[] args) {  new RtmpClientNew(); }}

?

热点排行