當前位置: 首頁>>代碼示例>>Java>>正文


Java Channel.disconnect方法代碼示例

本文整理匯總了Java中io.netty.channel.Channel.disconnect方法的典型用法代碼示例。如果您正苦於以下問題:Java Channel.disconnect方法的具體用法?Java Channel.disconnect怎麽用?Java Channel.disconnect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.netty.channel.Channel的用法示例。


在下文中一共展示了Channel.disconnect方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: manualRemoveChannel

import io.netty.channel.Channel; //導入方法依賴的package包/類
/**
 * 手動移除相應的 Channel
 *
 * @param channel 欲被手動移除的 Channel
 */
private void manualRemoveChannel(Channel channel) {
    if (channel.isActive()) {
        channel.disconnect();
    } else {
        removeChannelCompleted(channel);
    }
}
 
開發者ID:bitkylin,項目名稱:ClusterDeviceControlPlatform,代碼行數:13,代碼來源:TcpRepository.java

示例2: onHandshake

import io.netty.channel.Channel; //導入方法依賴的package包/類
@EventHandler
public void onHandshake(HandshakeEvent event) {
    Channel channel = event.getChannel();
    PacketHandshake packet = event.getPacket();

    String header = "auth";
    String version = Cloud.getInstance().getVersion();
    InetSocketAddress remoteAddress = (InetSocketAddress) channel.remoteAddress();

    // checks if address is allowed by the whitelist
    if(!Cloud.getInstance().getServer().getWhitelist().allowed(remoteAddress)) {
        packet.respond(new PacketRespond(header, version, ResponseStatus.FORBIDDEN));
        channel.disconnect();
    }

    // checks if the instance name is valid
    if(!Validation.INSTANCE_NAME.matches(packet.identifier)) {
        packet.respond(new PacketRespond(header, version, ResponseStatus.BAD_REQUEST));
        channel.disconnect();
        return;
    }

    // checks if already a daemon from this host connected to the server
    if(packet.type == ClientType.DAEMON && Cloud.getInstance().getClientManager().contains(remoteAddress)) {
        packet.respond(new PacketRespond(header, version, ResponseStatus.FORBIDDEN));
        channel.disconnect();
        return;
    }

    //.
    packet.respond(new PacketRespond(header, version, ResponseStatus.OK));

    // Add client
    MooClient client = new MooClient(packet.identifier,
            remoteAddress.getAddress().getHostAddress(),
            remoteAddress.getPort(), packet.subPort, packet.type, channel);
    client.setId(Cloud.getInstance().getClientManager().add(client));

    // fire event of client connection
    EventExecutor.getInstance().execute(new MooClientConnectedEvent(client));

    Cloud.getInstance().getLogger().debug(ConsoleColor.GREEN.toString()
            + client.getType() + " client connected @(" + remoteAddress.getAddress().getHostAddress() + ")");
}
 
開發者ID:Superioz,項目名稱:MooProject,代碼行數:45,代碼來源:HandshakeListener.java

示例3: handleError

import io.netty.channel.Channel; //導入方法依賴的package包/類
@Override
protected void handleError(ErrorMessage error, Channel channel) {
    super.handleError(error, channel);
    channel.disconnect();
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:6,代碼來源:BootstrapChannelHandler.java


注:本文中的io.netty.channel.Channel.disconnect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。