void Awake() { //Debug.Log ("NetDataRequestTip Awake"); startReq = StartNetRequest; endReq = EndNetRequest; ConnectClose = ConnectCloseRequest; }
public void GetQuickLoginInf(string deviceID, EventDispatcher.EventCallback eventCallback) { JsonObject msg = new JsonObject(); msg[DEVICE_ID] = deviceID; ConnectionManager.GetInstance().RequestData <LoginData>(CGNetConst.ROUTE_QUICKLOGIN, msg, eventCallback); }
public void GetItemBase(string guID, string posID, EventDispatcher.EventCallback eventCallback) { JsonObject msg = new JsonObject(); msg[GUID] = guID; msg[GUID] = posID; ConnectionManager.GetInstance().RequestData <PlayerInfo>(CGNetConst.ROUTE_BUILDING_UPDATE, msg, eventCallback); }
public RequestInfo(string route, string data, EventDispatcher.EventCallback eventCallback) { this.dataType = DataType.Type_String; this.route = route; this.data = data; this.eventCallback = eventCallback; reqTicks = DateTime.Now.Ticks; }
/// <summary> /// Requests the data by json string. /// 如果结构中有自定义类的话必须用这个方法。不然会造成请求发送不出去,原因是由于jsonObject对象的toString()方法不能吧自定义类转化 /// </summary> /// <param name="route">Route.</param> /// <param name="jsonData">Json data.</param> /// <param name="eventCallback">Event callback.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public void RequestDataByJsonStr <T>(string route, string jsonData, EventDispatcher.EventCallback eventCallback) { RequestInfo reqInfo = new RequestInfo(route, jsonData, eventCallback); reqInfo.request = () => { Request <T>(reqInfo); }; requestList.Add(reqInfo); Request <T>(reqInfo); }
/// <summary> /// 数据请求 只能发送简单的数据类型 /// Requests the data. /// </summary> /// <param name="route">Route.</param> /// <param name="data">Data.</param> /// <param name="eventCallback">Event callback.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public void RequestData <T>(string route, JsonObject data, EventDispatcher.EventCallback eventCallback) { RequestInfo reqInfo = new RequestInfo(route, data, eventCallback); reqInfo.request = () => { Request <T>(reqInfo); }; requestList.Add(reqInfo); Request <T>(reqInfo); }
/** * Compare function ptrs. * * Due to delegate wrapping in AS3 it is not possible to compare events in JS. **/ public bool compareToDelegate(EventDelegate delegateObj, EventDispatcher.EventCallback delegateCallback, bool useCapture) { #if UNITY_EDITOR if (delegateObj.delegateCallback == delegateCallback) #else if (ActionScript.Expression <bool>("({0} == {1})", delegateObj.delegateCallback, delegateCallback)) #endif { return(true); } #if UNITY_EDITOR // Fast check if (delegateObj.delegateCallback.GetHashCode() == delegateCallback.GetHashCode() && delegateObj.useCapture == useCapture) { return(true); } MulticastDelegate internalDelegate = cacheCompilerGenerated(delegateObj.delegateCallback); // Handle compilter genreated MulticastDelegate dOther = delegateCallback; if (dOther != null && internalDelegate != null && dOther.Target != null) { System.Object dTargetOther = (System.Object)dOther.Target; FieldInfo[] attrsB = dTargetOther.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance); if (attrsB.Length > 0) { if (attrsB[0].Name[0] == '$') { // Get as deledages MulticastDelegate B = attrsB[0].GetValue(dTargetOther) as MulticastDelegate; // Compare delegates bool cmp = internalDelegate == B; Debug.LogWarning("Event arg declared on " + B.Method.Name + ":" + B.Target + " must be CEvent, please refactor events for Flash player builds"); // Return return(cmp && delegateObj.useCapture == useCapture); } } } bool cmpB = delegateCallback == delegateObj.delegateCallback; // Default return(cmpB && delegateObj.useCapture == useCapture); #else return(false); #endif }
/// <summary> /// 监听服务器主动对送消息 /// </summary> /// <param name="eventName">Event name.</param> /// <param name="action">Action.</param>0 public void ReceivePushMsg <T>(string eventName, EventDispatcher.EventCallback eventCallback) { if (pclient == null) { Debug.Log("pclient is null"); } Debug.Log("=============ReceivePushMsgReceivePushMsgReceivePushMsg=================="); pclient.on(eventName, delegate(JsonObject resData) { EventDispatcher.Instance().RegistEventListener(eventName, eventCallback); Debug.Log("pushData=" + resData); CommonResult <T> commonResult = AnalysisData <T>(resData); EventDispatcher.Instance().DispatchEvent(eventName, commonResult); }); }
public LocalizedButton AddTranslationButton(MovieClip _mc, string _text, EventDispatcher.EventCallback BtnClickCallback, LocalizedButton.Alignment _alignment, bool _resizable = true, bool _icon = false, string _iconLabel = "") { LocalizedButton localizedButton; if (localizedButtonList.ContainsKey(_mc)) { localizedButtonList.TryGetValue(_mc, out localizedButton); //_translationText = new TranslationText(_textfield, txt); TODO } else { localizedButton = new LocalizedButton(_mc, _text, BtnClickCallback, _alignment, _resizable, _icon, _iconLabel); localizedButtonList.Add(_mc, localizedButton); } return(localizedButton); }
public LocalizedButton(MovieClip _mc, string _text, EventDispatcher.EventCallback _btnClickCallback, Alignment _alignment, bool _resizable, bool _icon, string _iconLabel) { mc = _mc; text = _text; //buttonType = _buttonType; btnClickCallback = _btnClickCallback; alignment = _alignment; resizable = _resizable; icon = _icon; iconLabel = _iconLabel; if (resizable) { rightMc = mc.getChildByName <MovieClip>("mcButtonRight"); leftMc = mc.getChildByName <MovieClip>("mcButtonLeft"); centerMc = mc.getChildByName <MovieClip>("mcButtonFill"); centerX = centerMc.x; leftX = leftMc.x; rightX = rightMc.x; } else { bgMc = mc.getChildByName <MovieClip>("mcButtonBg"); } iconMc = mc.getChildByName <MovieClip>("mcIcon"); if (!icon) { if (iconMc != null) { iconMc.visible = false; } //arrowMc = null; } //interfaces = GameObject.FindGameObjectWithTag("Interface").GetComponent<CQ_Interface>(); SetButtonEvents(); }
protected void RemoveEventListener <T1, T2, T3>(EventConstant code, EventDispatcher.EventCallback <T1, T2, T3> handler) { dispatcher.RemoveEventListener <T1, T2, T3>(code, handler); }
protected void AddEventListener <T1, T2>(EventConstant code, EventDispatcher.EventCallback <T1, T2> handler) { dispatcher.AddEventListener <T1, T2>(code, handler); }
protected void RemoveEventListener(EventConstant code, EventDispatcher.EventCallback handler) { dispatcher.RemoveEventListener(code, handler); }
public void GetBattleData(string guid, int copyID, List <int> propSkills, int supportPlayerID, EventDispatcher.EventCallback eventCallback) { JsonObject msg = new JsonObject(); msg[KEY_GUID] = guid; msg[KEY_COPYID] = copyID; msg[KEY_PROPSKILL] = propSkills; msg[KEY_SUPPORT] = supportPlayerID; //ConnectionManager.GetInstance().RequestData<StageMonsterData>(CGNetConst.ROUTE_BATTLE_READY, msg, eventCallback); }
//toggle true:界面显示时会自动添加侦听,隐藏时会自动删除侦听 false:界面初始化时自动添加侦听,释放时才删除侦听 protected void RegisterEventListener <T1, T2, T3>(EventConstant typeCode, EventDispatcher.EventCallback <T1, T2, T3> listener, bool toggle) { InternalRegisterEventListener(typeCode, listener, toggle); }