A web project was developed some time ago. The customer requested the instant message function:
1. The client cannot install software;
2. The client can receive instant messages without opening the webpage.
3. No matter whether the client is using any software, instant messages must be immediately visible to the customer.
Considering that the customer's network environment is a simple peer network, the work group is used to allocate various departments of the Organization, so the instant messaging service is used to solve the problem.
Below isCode, Hope you can provide comments and suggestions
Using system;
Using system. runtime. interopservices;
Namespace Test
{
/// <Summary>
/// Summary of netsend.
/// </Summary>
Public class netsend
{
Public netsend ()
{
//
// Todo: add the constructor logic here
//
}
Public int sendmessage (string sfrom, string sto, string smessage)
{
Byte [] bbuffer = system. Text. encoding. Unicode. getbytes (smessage );
Int nret = netmessagebuffersend (null, sto, null, smessage, smessage. length * 2 + 2 );
Return nret;
}
[Dllimport ("netapi32", charset = charset. Unicode)]
Public static extern int netmessagebuffersend (string servername, string msgname, string fromname, string Buf, int buflen );
}
}
Supplement the net send Syntax:
Net send {name | * |/domain [: Name] |/users} message