/**
Flash Socket IM Core(TCP)
例:
var im = new SocketImCore("im",document.all["Socket"]);
im.server = "192.168.1.34";
im.port = 6009;
im.Connect()

[构造函数]
SocketImCore(instance,flashSocketObj)	
	instance：							Js实例化对象名称
	flashSocketObj：					flash Dom对象

[属性]
instance								Js实例化对象名称
socket									flash Dom对象
server									IM服务器IP或是名称
port									IM服务器端口


[方法]
Connect()								连接
SendData()								发送数据

[事件]
OnClose()								连接关闭
OnConnected()							连接成功
OnError(msg)							错误
	msg:								错误消息
OnReceive(data)							接收到消息
	data:								接受到的消息数据
OnLog(log)								日志信息(调试用)
	log									日志信息内容
*/
function SocketImCore(instance,flashSocketObj)
{
	this.instance = instance;
	this.socket = null;
	this.server = null;
	this.port = null;
	this.OnClose=null;
	this.flashSocketObj = flashSocketObj;
	var _flashMe=this;

	SocketImCore.prototype.Connect = function ()
	{
		this.socket = _flashMe.flashSocketObj
		this.socket.SetInstance(_flashMe.instance);
		this.socket.Connect(this.server,this.port);
	}

	SocketImCore.prototype.SendData = function (data)
	{
		this.socket.SendData(data);
	}

	SocketImCore.prototype.Log = function(msg)
	{
		msg =decodeURIComponent(msg);
		if (this.OnLog != null)
		{
			this.OnLog(msg);
		}
	}

	SocketImCore.prototype.Close = function()
	{
		if (this.OnClose != null)
		{
			this.OnClose();
		}
	}

	SocketImCore.prototype.Connected =function(msg)
	{
		msg =decodeURIComponent(msg);
		if (this.OnConnected != null)
		{
			this.OnConnected(msg);
		}

	}
	SocketImCore.prototype.Error =function(msg)
	{
		if (this.OnError != null)
		{
			this.OnError(msg);
		}
	}

	SocketImCore.prototype.Received = function(data)
	{	
		data =decodeURIComponent(data);
		if (this.OnReceive != null)
		{
			this.OnReceive(data);
		}				
	}
	
}