static Defines() { switch (System.Environment.OSVersion.Platform) { case PlatformID.Win32S: case PlatformID.Win32NT: case PlatformID.Win32Windows: case PlatformID.Xbox: OperationSystem = tagOperationSystem.osWin; break; case PlatformID.WinCE: OperationSystem = tagOperationSystem.osWinCE; break; case PlatformID.Unix: OperationSystem = tagOperationSystem.osUnix; break; #if WINCE #else case PlatformID.MacOSX: OperationSystem = tagOperationSystem.osMac; break; #endif default: throw new NotSupportedException("Platform not supported"); } }
public static CUQueue Lock(tagOperationSystem os) { #if TASKS_ENABLED CUQueue UQueue; if (!m_sQueue.TryPop(out UQueue)) { UQueue = new CUQueue(); } #else CUQueue UQueue = null; lock (m_cs) { if (m_sQueue.Count > 0) { UQueue = m_sQueue.Pop(); } } if (UQueue == null) { UQueue = new CUQueue(); } #endif UQueue.OS = os; return(UQueue); }
public static CUQueue Lock(tagOperationSystem os) { CUQueue UQueue; if (!m_sQueue.TryDequeue(out UQueue)) { UQueue = new CUQueue(); } UQueue.OS = os; return(UQueue); }
internal virtual void OnChatComing(tagChatRequestID chatRequestID) { uint svsId = ServerCoreLoader.GetSvsID(m_sh); CUQueue q = m_qBuffer; if (svsId != BaseServiceID.sidHTTP) { bool endian = false; tagOperationSystem os = ServerCoreLoader.GetPeerOs(m_sh, ref endian); q.Endian = endian; q.OS = os; } switch (chatRequestID) { case tagChatRequestID.idEnter: { object objGroups; q.Load(out objGroups); OnSubscribe((uint[])objGroups); } break; case tagChatRequestID.idExit: { OnUnsubscribe(ChatGroups); } break; case tagChatRequestID.idSendUserMessage: { object msg; string user; q.Load(out user).Load(out msg); OnSendUserMessage(user, msg); } break; case tagChatRequestID.idSpeak: { object msg; object groups; q.Load(out groups).Load(out msg); OnPublish(msg, (uint[])groups); } break; default: ServerCoreLoader.SendExceptionResult(m_sh, "Unexpected chat request", Environment.StackTrace, (ushort)chatRequestID, 0); break; } }
public static CUQueue Lock(tagOperationSystem os) { CUQueue UQueue = null; lock (m_cs) { if (m_sQueue.Count > 0) { UQueue = m_sQueue[m_sQueue.Count - 1]; m_sQueue.RemoveAt(m_sQueue.Count - 1); } } if (UQueue == null) { UQueue = new CUQueue(); } UQueue.OS = os; return(UQueue); }
private void OnBRProcessed(IntPtr handler, ushort requestId) { if (requestId == (uint)tagBaseRequestID.idSwitchTo) { m_nCurrentSvsId = ClientCoreLoader.GetCurrentServiceId(handler); m_bRandom = (ClientCoreLoader.IsRandom(m_h) != 0); m_routing = (ClientCoreLoader.IsRouting(m_h) != 0); m_os = ClientCoreLoader.GetPeerOs(m_h, ref m_endian); } CAsyncServiceHandler ash = Seek(CurrentServiceID); if (ash != null) { ash.OnBProcessed(requestId); if ((tagBaseRequestID)requestId == tagBaseRequestID.idCancel) ash.CleanCallbacks(); } if (BaseRequestProcessed != null) BaseRequestProcessed.Invoke(this, (tagBaseRequestID)requestId); }
private void OnRProcessed(IntPtr handler, ushort requestId, uint len) { CAsyncServiceHandler ash = Seek(CurrentServiceID); if (ash != null) { using (CScopeUQueue su = new CScopeUQueue()) { uint res = 0; CUQueue q = su.UQueue; if (m_routing) m_os = ClientCoreLoader.GetPeerOs(handler, ref m_endian); q.OS = m_os; q.Endian = m_endian; if (q.MaxBufferSize < (len + 16)) q.Realloc(len + 16); if (len > 0) { unsafe { fixed (byte* buffer = q.m_bytes) { res = ClientCoreLoader.RetrieveResult(handler, buffer, len); } } } if (res != len) { if (res == 0) return; //socket closed //should never come here! string msg = string.Format("Wrong number of bytes retrieved (expected = {0} and obtained = {1})", len, res); throw new InvalidOperationException(msg); } q.SetSize(len); ash.onRR(requestId, q); } } if (RequestProcessed != null) { RequestProcessed.Invoke(this, requestId, len); } }