diff --git a/Http.alusus b/Http.alusus index 4f04af2..94c20ea 100644 --- a/Http.alusus +++ b/Http.alusus @@ -91,6 +91,13 @@ module Http { class Connection { }; + // connection user data + @expname[mg_set_user_connection_data] + func setUserConnectionData (connection: ptr[Connection], data : ptr[Void]); + + @expname[mg_get_user_connection_data] + func getUserConnectionData (connection: ptr[Connection]) : ptr[Void]; + // WebSocket Types def WebSocketConnectCallback: alias ptr[func (connection: ptr[Connection], userData: ptr[Void]): Int]; def WebSocketReadyCallback: alias ptr[func (connection: ptr[Connection], userData: ptr[Void]): Void]; diff --git a/README.ar.md b/README.ar.md index dd543f8..363f5d8 100644 --- a/README.ar.md +++ b/README.ar.md @@ -1220,6 +1220,53 @@ def mutex: int[64]; يمكن استعمالها لقفل الاتصال من أجل الوصول المتزامن الآمن. +### عين_بيانات_إتصال_المستخدم (setUserConnectionData) + +``` +@تصدير[mg_set_user_connection_data] +دالة عين_بيانات_إتصال_المستخدم(اتصال: مؤشر[اتـصال]، بيانات_المستخدم: مؤشر[فـراغ])؛ +``` + +
+ +``` +@expname[mg_set_user_connection_data] +func setUserConnectionData (connection: ptr[Connection], userData : ptr[Void]); +``` + +
+ +يسجل مؤشر بيانات إلى اتصال. + +* `اتصال` (`connection`) : مؤشر إلى الاتصال الذي تريد تسجيل البيانات فيه. +* `بيانات_المستخدم` (`userData`) : مؤشر للبيانات التي تريد تسجيلها. + +يؤدي استدعاء هذه الدالة مرة أخرى على نفس مؤشر الاتصال إلى استبدال أي مؤشر بيانات مسجل مسبقًا. + +يمكنك استرداد البيانات المسجلة عن طريق استدعاء دالة `هات_بيانات_إتصال_المستخدم (getUserConnectionData)`. + +### هات_بيانات_إتصال_المستخدم (getUserConnectionData) + +``` +@تصدير[mg_get_user_connection_data] +دالة هات_بيانات_إتصال_المستخدم(اتصال: مؤشر[اتـصال]): مؤشر[فـراغ]؛ +``` + +
+ +``` +@expname[mg_get_user_connection_data] +func getUserConnectionData (connection: ptr[Connection]) : ptr[Void]; +``` + +
+ +تُعيد هذه الدالة مؤشر البيانات الذي تم تسجيله مسبقًا للاتصال عبر `عين_بيانات_إتصال_المستخدم (setUserConnectionData)`. + +* `اتصال` (`connection`) : مؤشر إلى الاتصال الذي تريد الحصول على البيانات المسجلة فيه. + +يُرجع `عدم` (`null`) إذا لم يتم تسجيل أي بيانات لهذا الاتصال بعد. + ### شغل_الخادم (startServer) ``` diff --git a/README.md b/README.md index 3e7b836..3bd746d 100644 --- a/README.md +++ b/README.md @@ -568,6 +568,35 @@ def mutex: int[64] ``` Used for locking when we need to access synced data safely. +### setUserConnectionData + +``` +@expname[mg_set_user_connection_data] +func setUserConnectionData (connection: ptr[Connection], data : ptr[Void]); +``` + +Registers a data pointer to a connection. + +* `connection` : pointer to the connection you want to register data to. +* `userData` : pointer for data you want to register. + +Calling this function again on the same connection pointer overwrites any previously registered data pointer. + +You can retrieve the registered data by calling `getUserConnectionData`; + +### getUserConnectionData + +``` +@expname[mg_get_user_connection_data] +func getUserConnectionData (connection: ptr[Connection]) : ptr[Void]; +``` + +This function returns the data pointer that was previously registered for a connection via `setUserConnectionData`. + +* `connection` : pointer to the connection you want to get the data that was registered to. + +Returns `null` if no data has been registered yet for this connection. + ### startServer ``` diff --git "a/\330\250\331\200\331\206\331\206\330\252.\330\243\330\263\330\263" "b/\330\250\331\200\331\206\331\206\330\252.\330\243\330\263\330\263" index d3572ef..bbae1bc 100644 --- "a/\330\250\331\200\331\206\331\206\330\252.\330\243\330\263\330\263" +++ "b/\330\250\331\200\331\206\331\206\330\252.\330\243\330\263\330\263" @@ -71,6 +71,9 @@ عرف اتـصال: لقب Connection؛ + عرف عين_بيانات_إتصال_المستخدم: لقب setUserConnectionData؛ + عرف هات_بيانات_إتصال_المستخدم: لقب getUserConnectionData؛ + // أصناف ويب سوكت عرف مـنادى_اتصال_ويب_سوكت: لقب WebSocketConnectCallback؛ عرف مـنادى_استعداد_ويب_سوكت: لقب WebSocketReadyCallback؛