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

📄 constants.java

📁 利用mina框架写的一个通信实例。初学者的一个好教程。
💻 JAVA
字号:
/*
 *   @(#) $Id: Constants.java 357871 2005-12-20 01:56:40Z trustin $
 *
 *   Copyright 2004 The Apache Software Foundation
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
package org.apache.mina.examples.call;

import java.nio.ByteOrder;

/**
 * Provides SumUp protocol constants.
 * 
 * @author The Apache Directory Project
 * @version $Rev: 357871 $, $Date: 2005-12-20 10:56:40 +0900 (Tue, 20 Dec 2005) $
 */
public class Constants {

	// head length
	public static final int HEAD_LEN_LENGTH = 4;

	public static final int HEAD_LEN_COMMAND = 4;

	public static final int HEAD_LEN_SEQUENCE = 4;

	// head length is 12
	public static final int HEADER_LEN_SUM = HEAD_LEN_LENGTH + HEAD_LEN_COMMAND
			+ HEAD_LEN_SEQUENCE;

	// body length
	public static final int BODY_LEN_LOGIN = 131; // CALLOUT_LOGIN_MSG ?114?
													// lk

	public static final int BODY_LEN_LOGIN_RESPONSE = 8; // CALLOUT_LOGIN_MSG_RESP
															// lk

	public static final int BODY_LEN_LOGOUT = 0;

	public static final int BODY_LEN_LOGOUT_RESPONSE = 0;

	public static final int BODY_LEN_CALL_OUT = 132; // CALLOUT_SEND_MSG lk

	public static final int BODY_LEN_CALL_OUT_RESPONSE = 0;

	public static final int BODY_LEN_CALL_OUT_RESULT = 70; // CALL_OUT_RESULT_MSG
															// lk

	public static final int BODY_LEN_CALL_OUT_RESULT_RESPONSE = 0;

	public static final int BODY_LEN_CALL_HANG = 66; // CALL_HANG_MSG lk

	public static final int BODY_LEN_CALL_HANG_RESPONSE = 0;

	public static final int BODY_LEN_CALL_IN = 66; // CALL_IN_MSG lk

	public static final int BODY_LEN_CALL_IN_RESPONSE = 0;

	public static final int BODY_LEN_ACTIVE_TEST = 0;

	public static final int BODY_LEN_ACTIVE_TEST_RESPONSE = 0;

	// message total length
	public static final int MESSAGE_LEN_LOGIN = HEADER_LEN_SUM + BODY_LEN_LOGIN;

	public static final int MESSAGE_LEN_LOGIN_RESPONSE = HEADER_LEN_SUM
			+ BODY_LEN_LOGIN_RESPONSE;

	public static final int MESSAGE_LEN_LOGOUT = HEADER_LEN_SUM
			+ BODY_LEN_LOGOUT;

	public static final int MESSAGE_LEN_LOGOUT_RESPONSE = HEADER_LEN_SUM
			+ BODY_LEN_LOGOUT_RESPONSE;

	public static final int MESSAGE_LEN_CALL_OUT = HEADER_LEN_SUM
			+ BODY_LEN_CALL_OUT;

	public static final int MESSAGE_LEN_CALL_OUT_RESPONSE = HEADER_LEN_SUM
			+ BODY_LEN_CALL_OUT_RESPONSE;

	public static final int MESSAGE_LEN_CALL_OUT_RESULT = HEADER_LEN_SUM
			+ BODY_LEN_CALL_OUT_RESULT;

	public static final int MESSAGE_LEN_CALL_OUT_RESULT_RESPONSE = HEADER_LEN_SUM
			+ BODY_LEN_CALL_OUT_RESULT_RESPONSE;

	public static final int MESSAGE_LEN_CALL_HANG = HEADER_LEN_SUM 				// add lk.
			+ BODY_LEN_CALL_HANG;

	public static final int MESSAGE_LEN_CALL_HANG_RESPONSE = HEADER_LEN_SUM		// add lk.
			+ BODY_LEN_CALL_HANG_RESPONSE;

	public static final int MESSAGE_LEN_CALL_IN = HEADER_LEN_SUM
			+ BODY_LEN_CALL_IN;

	public static final int MESSAGE_LEN_CALL_IN_RESPONSE = HEADER_LEN_SUM
			+ BODY_LEN_CALL_IN_RESPONSE;

	public static final int MESSAGE_LEN_ACTIVE_TEST = HEADER_LEN_SUM
			+ BODY_LEN_ACTIVE_TEST;

	public static final int MESSAGE_LEN_ACTIVE_TEST_RESPONSE = HEADER_LEN_SUM
			+ BODY_LEN_ACTIVE_TEST_RESPONSE;

	// message type difine
	public static final int TYPE_LOGIN = 0x000001;// login

	public static final int TYPE_LOGIN_RESPONSE = 0x800001;// login responses

	public static final int TYPE_LOGOUT = 0x000002;

	public static final int TYPE_LOGOUT_RESPONSE = 0x800002;

	public static final int TYPE_CALL_OUT = 0x000003;

	public static final int TYPE_CALL_OUT_RESPONSE = 0x800003;

	public static final int TYPE_ACTIVE_TEST = 0x000004;

	public static final int TYPE_ACTIVE_TEST_RESPONSE = 0x800004;
	
	public static final int TYPE_CALL_HANG = 0x000007;			// add lk

	public static final int TYPE_CALL_HANG_RESPONSE = 0x800007;	// add lk

	public static final int TYPE_CALL_IN = 0x000005;

	public static final int TYPE_CALL_IN_RESPONSE = 0x800005;

	public static final int TYPE_CALL_OUT_RESULT = 0x000006;

	public static final int TYPE_CALL_OUT_RESULT_RESPONSE = 0x800006;

	// int code order
	public static final ByteOrder BYTE_ORDER = ByteOrder.BIG_ENDIAN;

	public static final int IDLE_SECOND = 15; // 60; idle second.// modify lk.

	public static final int LOGIN_MESSAGE_BODY_USER_LENGTH = 51;// 51 bytes

	public static final int LOGIN_MESSAGE_BODY_PASSWORD_LENGTH = 21;// 21 bytes

	public static final int LOGIN_MESSAGE_BODY_COMMENT_LENGTH = 51;// 51 bytes
	
	//
	public static final int CALL_HANG_MESSAGE_BODY_CALLER_LENGTH = 22;	// add. lk

	public static final int CALL_HANG_MESSAGE_BODY_ZONE_LENGTH = 23;

	public static final int CALL_HANG_MESSAGE_BODY_RESERVE_LENGTH = 21;
	//

	public static final int CALL_IN_MESSAGE_BODY_CALLER_LENGTH = 22;

	public static final int CALL_IN_MESSAGE_BODY_ZONE_LENGTH = 23;

	public static final int CALL_IN_MESSAGE_BODY_RESERVE_LENGTH = 21;

	public static final int CALL_OUT_MESSAGE_BODY_DEST_LENGTH = 22;

	public static final int CALL_OUT_MESSAGE_BODY_DISPLAY_LENGTH = 22;

	public static final int CALL_OUT_MESSAGE_BODY_RESERVE_LENGTH = 21;

	public static final int CALL_OUT_MESSAGE_BODY_SERVICE_LENGTH = 11;

	public static final int CALL_OUT_MESSAGE_BODY_SRC_LENGTH = 33;

	public static final int CALL_OUT_MESSAGE_BODY_ZONE_LENGTH = 23;

	public static final int CALL_OUT_RESULT_MESSAGE_BODY_DISPLAY_LENGTH = 22;

	public static final int CALL_OUT_RESULT_MESSAGE_BODY_ZONE_LENGTH = 23;

	public static final int CALL_OUT_RESULT_MESSAGE_BODY_RESERVE_LENGTH = 21;

	public static int nextSequenceId;

	private Constants() {
	}

}

⌨️ 快捷键说明

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