⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plainchannel.java

📁 Examples to create your Conferencing System in .NET, C# VOIP & Video Conferencing Systems using H.32
💻 JAVA
字号:
/*
 * Copyright 2004 WIT-Software, Lda. 
 * - web: http://www.wit-software.com 
 * - email: info@wit-software.com
 *
 * All rights reserved. Relased under terms of the 
 * Creative Commons' Attribution-NonCommercial-ShareAlike license.
 */
package handlers;

import io.SelectorThread;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel;

/**
 * @author Nuno Santos
 */
public final class PlainChannel extends Channel {
	/**
	 * @param st
	 * @param sc
	 * @param listener
	 * @throws IOException
	 */
	public PlainChannel(SelectorThread st, SocketChannel sc, ChannelListener listener) throws IOException {
		super(st, sc, listener);		
		st.registerChannelNow(sc, 0, this);
	}

	public int read(ByteBuffer dst) throws IOException {
		return sc.read(dst);
	}

	public int write(ByteBuffer src) throws IOException {
		return sc.write(src);
	}

	public void registerForRead() throws IOException {
    st.addChannelInterestNow(sc, SelectionKey.OP_READ);
	}

	public void registerForWrite() throws IOException {		
		st.addChannelInterestNow(sc, SelectionKey.OP_WRITE);
	}

	public void unregisterForRead() throws IOException {
		st.removeChannelInterestNow(sc, SelectionKey.OP_READ);
	}

	public void unregisterForWrite() throws IOException {
		st.removeChannelInterestNow(sc, SelectionKey.OP_WRITE);
	}
	
	public void close() throws IOException {
		sc.close();		
	}

	public void handleRead() {
		listener.handleRead();		
	}

	public void handleWrite() {
		listener.handleWrite();		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -