How to Receive a Message through Named Pipe

This sample demonstrates how to receive a message using the named pipe of the Info service.

File ReceiveMessage.vbs used in this sample is located in the folder:

    C:\Program Files\CodeSegment\SMS Studio\Samples\InfoService

This script opens a named pipe instance and sends a messages that will be placed in the SMS Studio Inbox and then processed as if it was received through an ordinary connection.

The contents of the ReceiveMessage.vbs file:

'-------------------------------------------------------------------------------------------------------------------------------
' This script demonstrates how to receive a text message using Info Service Named Pipe.
' After this script is executed a message will appear in the Inbox window.
' WARNING: Error checking omitted for clarity.
'-------------------------------------------------------------------------------------------------------------------------------

PipeName = "ReceivePipe"                              ' Name of the pipe
                                                      ' This value must be specified in the Info Setup dialog

set fso = CreateObject("Scripting.FileSystemObject")
set pipe = fso.CreateTextFile("\\.\pipe\" & PipeName) ' Open the pipe instance

pipe.WriteLine("From: +44446666")                     ' Sender
pipe.WriteLine("To: 7777")                            ' Recipient

pipe.WriteLine("AccountID: Emulator #1")              ' Account for receiving
                                                      ' Account ID should be taken from the Edit Connection dialog

pipe.WriteLine("Body: Test message.")                 ' Text of the message
pipe.WriteLine("NewLine: This is a new line.")        ' Optionally add a new line of text

pipe.WriteLine("<Receive>")                           ' Receive the message

pipe.Close                                            ' Close the pipe instance

WScript.Quit(0)                                       ' Exit

'-------------------------------------------------------------------------------------------------------------------------------
' Copyright (c) 2002-2006 CodeSegment. All rights reserved.                                          http://www.codesegment.com/
'-------------------------------------------------------------------------------------------------------------------------------

How to run this sample

  1. Click the New button on the main toolbar and select the Info service option in the New Service dialog.
  2. Click the Setup button on the main toolbar to display the Info Setup dialog.
  3. In the Advanced tab enter the name of the pipe:
    Pipe name: ReceivePipe
  4. Click the OK button to close the Info Setup dialog.
  5. Open Windows Explorer and locate the ReceiveMessage.vbs file. Double-click on this file to run the script.
  6. Check the Inbox window to see that the test message has been received.

Related topics

Named Pipe

 

Copyright © 2002-2007 CodeSegment. All rights reserved.

   www.codesegment.com