package com.mercury.chat.common.constant;

import org.apache.commons.lang.ObjectUtils;

import com.mercury.chat.common.struct.IMessage;

public enum StatusCode {
	OK(200, "Operate Success"), 
	FAIL(400, "Operate Failure"),
	UNAUTHORIZED(401, "Unauthorized"), 
	INTERNAL_SERVER_ERROR(500, "Internal Server Error"),
	SERVICE_UNAVAILABLE(503, "Service Unavailable"),
	NOT_LOGIN(600, "Invalid operation:not logged in"),
	LOGGED_IN(601, "Invalid operation:already logged in"),
	USER_LOGIN(700, "User Login"),
	USER_LOGOFF(701, "User Logoff");
	
	private int key;
	
	private String message;

	private StatusCode(int key, String message) {
		this.key = key;
		this.message = message;
	}

	public int key() {
		return key;
	}

	public String message() {
		return message;
	}

	public boolean $(IMessage message) {
		return ObjectUtils.equals(key(), message.getHeader().getStatusCode());
	}

}

@@ -189,20 +189,92 @@
 uccess%22)
+%7B%0D%0A%09%09@Override%0D%0A%09%09public boolean isFailed() %7B%0D%0A%09%09%09return false;%0D%0A%09%09%7D%0D%0A%09%7D
 , %0D%0A
-
 %09FAIL(40
@@ -585,43 +585,187 @@
 in%22)
-,%0D%0A%09USER_LOGOFF(701, %22User Logoff%22)
+%7B%0D%0A%09%09@Override%0D%0A%09%09public boolean isFailed() %7B%0D%0A%09%09%09return false;%0D%0A%09%09%7D%0D%0A%09%7D,%0D%0A%09USER_LOGOFF(701, %22User Logoff%22)%7B%0D%0A%09%09@Override%0D%0A%09%09public boolean isFailed() %7B%0D%0A%09%09%09return false;%0D%0A%09%09%7D%0D%0A%09%7D
 ;%0D%0A%09
@@ -814,18 +814,19 @@
 ssage;%0D%0A
+%09
 %0D%0A
-
 %09private
@@ -884,16 +884,16 @@
 = key;%0D%0A
-
 %09%09this.m
@@ -906,32 +906,84 @@
  = message;%0D%0A%09%7D%0D
+%0A%09%0D%0A%09public boolean isFailed()%7B%0D%0A%09%09return true;%0D%0A%09%7D%0D
 %0A%0D%0A%09public int k

add util method to check the response is ok or not.