ORSocketsCore (2.0.5)
Published 2026-06-04 10:21:46 -04:00 by ccurran
Installation
dotnet nuget add source --name OnRampSDK --username your_username --password your_token dotnet add package --source OnRampSDK --version 2.0.5 ORSocketsCoreAbout this package
OnRamp Public Sockets Core Library
OnRamp Sockets Core
VB.NET client library for OnRamp socket and shop monitor event handling.
Install
Public read access:
dotnet nuget add source https://git.onramp-solutions.com/api/packages/OnRampSDK/nuget/index.json --name onrampsdk
Install the package:
dotnet add package ORSocketsCore --source onrampsdk
Basic Usage
Imports ORSocketsCore
Dim socketClient = New ORSocketClient(
"https://onramp.customer.com/ProductionCopy/",
"SHOPMONITORCLIENT",
"SITE1001"
)
AddHandler socketClient.OnMessageReceived, AddressOf SocketMessageRec
AddHandler socketClient.OnLog, AddressOf SocketLog
The constructor opens a background socket connection and subscribes the client to the supplied group and ID.
Receiving Messages
Use OnMessageReceived to handle incoming socket messages.
Private Sub SocketMessageRec(obj As Object, e As ORSocketMessageReceivedArgs)
Console.WriteLine(e.senderGroup)
Console.WriteLine(e.senderName)
Console.WriteLine(e.msgTime)
Console.WriteLine(e.msg)
End Sub
Logging
Use OnLog to capture connection, reconnect, and socket debug messages.
Private Sub SocketLog(obj As Object, msg As String)
Console.WriteLine(msg)
End Sub
Shop Monitor Events
Shop monitor messages can be split on character 175 to get the device ID, channel number, and event type.
Dim msgSplit() As String = Split(e.msg, Convert.ToChar(175))
Dim deviceId As String = msgSplit(0)
Dim channelNum As Integer = CInt(msgSplit(1))
Dim eventType As ShopMonitorChannelEvent = CType(CInt(msgSplit(2)), ShopMonitorChannelEvent)
Cleanup
Dispose the client when the application exits.
socketClient.Dispose()
Full Example
The full example code is included below.
Imports System.Threading
Imports ORSocketsCore
Module Program
Private socketClient As ORSocketClient
Private quitEvent As New ManualResetEvent(False)
Sub Main(args As String())
' The http_root endpoint - use the main webserver, not a farm.
' Use ProdCopy for testing if needed.
Dim envUrl As String = "https://onramp.site.com/PROD/"
' Create a socket connection to OnRamp Server to receive shop monitor events.
' Register as a client app number. In this example we use SITE1001.
socketClient = New ORSocketClient(envUrl, "SHOPMONITORCLIENT", "SITE1001")
' Bind incoming interrupt socket messages to a subroutine.
AddHandler socketClient.OnMessageReceived, AddressOf SocketMessageRec
' Bind websocket debug and reconnect log messages.
AddHandler socketClient.OnLog, AddressOf SocketLog
' Wait forever and handle incoming socket events through SocketMessageRec.
WaitForConsoleExit()
End Sub
Private Sub SocketMessageRec(obj As Object, e As ORSocketMessageReceivedArgs)
Try
' You get message details like who sent it and when.
Dim senderGroup = e.senderGroup
Dim senderName = e.senderName
Dim msgTime = e.msgTime
Dim msg = e.msg
' You get a message array split by character 175.
Dim msgSplit() As String = Split(msg, Convert.ToChar(175))
' msg = deviceid, channelNum, eventType
Dim deviceId As String = msgSplit(0)
Dim channelNum As Integer = CInt(msgSplit(1))
Dim eventType As ShopMonitorChannelEvent = CType(CInt(msgSplit(2)), ShopMonitorChannelEvent)
Console.WriteLine("SenderGroup = " & senderGroup)
Console.WriteLine("SenderName = " & senderName)
Console.WriteLine("MsgTime = " & msgTime)
Console.WriteLine("DeviceId = " & deviceId)
Console.WriteLine("ChannelNum = " & channelNum)
Console.WriteLine("EventType = " & eventType.ToString())
' Tie into event types.
Select Case eventType
Case ShopMonitorChannelEvent.WorkOrderLogin
Console.WriteLine("New work order logged in.")
Case ShopMonitorChannelEvent.WorkOrderLogout
Console.WriteLine("Work order logged out.")
Case ShopMonitorChannelEvent.CycleStart
Console.WriteLine("Cycle start.")
Case ShopMonitorChannelEvent.CycleDone
Console.WriteLine("Cycle done.")
Case Else
Console.WriteLine("Other event received.")
End Select
' With this information you can get all you want to know about the work order
' using the OnRamp public API package if needed.
Catch ex As Exception
Console.WriteLine("SocketMessageRec error: " & ex.Message)
End Try
End Sub
Private Sub SocketLog(obj As Object, msg As String)
Console.WriteLine(msg)
End Sub
Private Sub WaitForConsoleExit()
Console.WriteLine("Running. Press Ctrl+C to exit.")
AddHandler Console.CancelKeyPress, AddressOf ConsoleCancel
' Block here until Ctrl+C.
quitEvent.WaitOne()
Console.WriteLine("Shutting down...")
Try
socketClient?.Dispose()
Catch
End Try
End Sub
Private Sub ConsoleCancel(sender As Object, eArgs As ConsoleCancelEventArgs)
quitEvent.Set()
eArgs.Cancel = True
End Sub
End Module
Dependencies
Details
2026-06-04 10:21:46 -04:00
Assets (2)
Versions (2)
View all
NuGet
18
Craig Curran
14 KiB
orsocketscore.2.0.5.nupkg
13 KiB
orsocketscore.nuspec
1.0 KiB