当前位置: 首页>>代码示例>>Java>>正文


Java Transport.UDP属性代码示例

本文整理汇总了Java中org.ice4j.Transport.UDP属性的典型用法代码示例。如果您正苦于以下问题:Java Transport.UDP属性的具体用法?Java Transport.UDP怎么用?Java Transport.UDP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.ice4j.Transport的用法示例。


在下文中一共展示了Transport.UDP属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addNewPermission

/**
 * Adds a new Permission for this Allocation.
 * 
 * @param permission the permission to be added to this allocation.
 */
public void addNewPermission(Permission permission)
{
    TransportAddress peerAddr =
        new TransportAddress(permission.getIpAddress().getAddress(), 0,
            Transport.UDP);
    if (this.permissions.containsKey(peerAddr))
    {
        this.permissions.get(permission.getIpAddress()).refresh();
    }
    else if (!this.canHaveMorePermisions())
    {
        return;
    }
    else
    {
        this.permissions.put(
            permission.getIpAddress(), permission);
        maybeStartPermissionExpireThread();
    }
}
 
开发者ID:jitsi,项目名称:turnserver,代码行数:25,代码来源:Allocation.java

示例2: addChannelBind

/**
 * Binds a new Channel to this Allocation.
 * If an existing ChannelBind is found it is refreshed
 * else a new ChannelBind and permission is added.
 * 
 * @param channelBind the channelBind to be added to this allocation.
 * @throws IllegalArgumentException if the channelNo of the channelBind to
 *             be added is already occupied.
 */
public void addChannelBind(ChannelBind channelBind)
{
    TransportAddress peerAddr =
        new TransportAddress(
                channelBind.getPeerAddress().getAddress(),
                0, 
                Transport.UDP);
    if (isBadChannelRequest(channelBind))
    {
        throw new IllegalArgumentException("400: BAD REQUEST");
    }
    else if(!channelBindings.containsKey(channelBind.getChannelNo()) 
           && !peerToChannelMap.containsKey(channelBind.getPeerAddress()))
    {
        synchronized(this.channelBindings)
        {
            this.channelBindings.put(   channelBind.getChannelNo(),
                                        channelBind);
        }
        synchronized(this.peerToChannelMap)
        {
            this.peerToChannelMap.put(
                channelBind.getPeerAddress(), channelBind.getChannelNo());
        }
    }
    else
    {
        synchronized(this.channelBindings)
        {
            this.channelBindings.get(channelBind.getChannelNo()).refresh();
        }
    }
    this.addNewPermission(peerAddr);
    maybeStartChannelBindExpireThread();
}
 
开发者ID:jitsi,项目名称:turnserver,代码行数:44,代码来源:Allocation.java

示例3: parseCandidate

/**
 * Parses the <tt>attribute</tt>.
 *
 * @param attribute the attribute that we need to parse.
 * @param stream the {@link org.ice4j.ice.IceMediaStream} that the candidate is supposed
 * to belong to.
 *
 * @return a newly created {@link org.ice4j.ice.RemoteCandidate} matching the
 * content of the specified <tt>attribute</tt> or <tt>null</tt> if the
 * candidate belonged to a component we don't have.
 */
private static RemoteCandidate parseCandidate(Attribute      attribute,
                                              IceMediaStream stream)
{
    String value = null;

    try{
        value = attribute.getValue();
    }catch (Throwable t){}//can't happen

    StringTokenizer tokenizer = new StringTokenizer(value);

    //XXX add exception handling.
    String foundation = tokenizer.nextToken();
    int componentID = Integer.parseInt( tokenizer.nextToken() );
    Transport transport = Transport.parse(tokenizer.nextToken());
    long priority = Long.parseLong(tokenizer.nextToken());
    String address = tokenizer.nextToken();
    int port = Integer.parseInt(tokenizer.nextToken());

    TransportAddress transAddr
        = new TransportAddress(address, port, transport);

    tokenizer.nextToken(); //skip the "typ" String
    CandidateType type = CandidateType.parse(tokenizer.nextToken());

    Component component = stream.getComponent(componentID);

    if(component == null)
        return null;

    // check if there's a related address property

    RemoteCandidate relatedCandidate = null;
    if (tokenizer.countTokens() >= 4)
    {
        tokenizer.nextToken(); // skip the raddr element
        String relatedAddr = tokenizer.nextToken();
        tokenizer.nextToken(); // skip the rport element
        int relatedPort = Integer.parseInt(tokenizer.nextToken());

        TransportAddress raddr = new TransportAddress(
                        relatedAddr, relatedPort, Transport.UDP);

        relatedCandidate = component.findRemoteCandidate(raddr);
    }

    RemoteCandidate cand = new RemoteCandidate(transAddr, component, type,
                    foundation, priority, relatedCandidate);

    component.addRemoteCandidate(cand);

    return cand;
}
 
开发者ID:hankcs,项目名称:IceNAT,代码行数:64,代码来源:SdpUtils.java

示例4: startAddressFetch

private synchronized void startAddressFetch() {
	if( addressFetchThread != null )
		return;
	addressFetchThread = new Thread() {
		@Override
		public void run() {
			Record[] stunRecords = null;
			Record[] turnRecords = null;
			for( int i=0; i<hosts.length; ++i ) {
				String stunQuery = "_stun._udp." + hosts[i] ;
				String turnQuery = "_turn._udp." + hosts[i] ;
				
				try {
					if( stunRecords == null )
						stunRecords = lookupSrv( stunQuery );
					if( turnRecords == null )
						turnRecords = lookupSrv( turnQuery );
					if( stunRecords != null && turnRecords != null )
						break;
				} catch( TextParseException tpe ) {
					throw new RuntimeException( tpe );
				}
			}
			if( stunRecords == null ) {
				stunAddresses = null ;
			} else {
				stunAddresses = new TransportAddress[stunRecords.length];
				for( int i=0; i<stunRecords.length; ++i ) {
					SRVRecord srv = (SRVRecord) stunRecords[i] ;
					stunAddresses[i] = new TransportAddress(srv.getTarget().toString().replaceFirst("\\.$", ""), srv.getPort(), Transport.UDP);
				}
			}
			if( turnRecords == null ) {
				turnAddresses = null ;
			} else {
				turnAddresses = new TransportAddress[stunRecords.length];
				for( int i=0; i<turnAddresses.length; ++i ) {
					SRVRecord srv = (SRVRecord) turnRecords[i] ;
					turnAddresses[i] = new TransportAddress(srv.getTarget().toString().replaceFirst("\\.$", ""), srv.getPort(), Transport.UDP);
				}
			}
		}

		private Record[] lookupSrv(String query) throws TextParseException {
			while( true ) {
				try {
					// Bug 6427854 causes this to sometimes throw an NPE
					return new Lookup( query, Type.SRV ).run();
				} catch( NullPointerException npe ) {
					Thread.yield();
				}
			}
		}
	};
	addressFetchThread.start();
}
 
开发者ID:bejayoharen,项目名称:java-bells,代码行数:56,代码来源:StunTurnAddress.java


注:本文中的org.ice4j.Transport.UDP属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。