Forum > General

Is it possible to send message in users in database?

(1/2) > >>

rdny:
Is it possible to send message in users on database?  Like a messenger but Using only database. I'm not using any network components btw :D.

balazsszekely:

--- Quote from: rdny on December 18, 2018, 03:02:29 am ---Is it possible to send message in users on database?  Like a messenger but Using only database. I'm not using any network components btw :D.

--- End quote ---
Firebird has a feature called "Events", which is not available in other database management systems. Events are notification messages sent asynchronously from server to clients. If you're not a firebird user, just create a table("Messages" for example), with the following fields:

ID(integer) -->unique id
FROM_ID(integer) --> sender's id *
TO_ID(integer) --> receiver's id *
DATETIME(timestamp) --> when the message was sent
TEXT(varchar or blob)-->message text
STATUS(integer)-->message status(0 -> not received,  1-->received)
* I assume each user has an uniqiue id, if not you should redesing the database

When a user wish to send a message, just insert a new record into the table with the appropriate data.
From time to time, each client will fetch the table, if the client's id and "to_id" are the same, plus the message "status" is zero, display the message to the user, then change status to 1. You can move messages with status 1 to a history table to avoid bloating. 

rdny:

--- Quote from: GetMem on December 18, 2018, 07:04:03 am ---
--- Quote from: rdny on December 18, 2018, 03:02:29 am ---Is it possible to send message in users on database?  Like a messenger but Using only database. I'm not using any network components btw :D.

--- End quote ---
Firebird has a feature called "Events", which is not available in other database management systems. Events are notification messages sent asynchronously from server to clients. If you're not a firebird user, just create a table("Messages" for example), with the following fields:

ID(integer) -->unique id
FROM_ID(integer) --> sender's id *
TO_ID(integer) --> receiver's id *
DATETIME(timestamp) --> when the message was sent
TEXT(varchar or blob)-->message text
STATUS(integer)-->message status(0 -> not received,  1-->received)
* I assume each user has an uniqiue id, if not you should redesing the database

When a user wish to send a message, just insert a new record into the table with the appropriate data.
From time to time, each client will fetch the table, if the client's id and "to_id" are the same, plus the message "status" is zero, display the message to the user, then change status to 1. You can move messages with status 1 to a history table to avoid bloating.

--- End quote ---


Hi I understand but, how will I code it in Laz? Can you send me a sample? Sorry I'm a beginner in Pascal Programming. Thanks Getmem!  :D

balazsszekely:

--- Quote ---Hi I understand but, how will I code it in Laz? Can you send me a sample? Sorry I'm a beginner in Pascal Programming.
--- End quote ---
I can help with the details, but unfortunately I don't have enough free time to code a full application.

rdny:

--- Quote from: GetMem on December 19, 2018, 01:47:30 pm ---
--- Quote ---Hi I understand but, how will I code it in Laz? Can you send me a sample? Sorry I'm a beginner in Pascal Programming.
--- End quote ---
I can help with the details, but unfortunately I don't have enough free time to code a full application.

--- End quote ---


It's okay, I appreciated your help. Thanks! :D

Navigation

[0] Message Index

[#] Next page

Go to full version