Error accessing ...\manager.dat: Error reading reply header from server
The simple Solution is to execute EmLibrary startUp.
More elegant would be to have Smalltalk catching the Operating System wake-up event and informing each application in the manner of restart, startUp or exiting / shutDown methods in SubApplication.
The following code defines an application for doing this under Windows. When going to standby each subapplication receives #fallAsleep. When waking up #wakeUp is send. As an example is #reconnectToDefaultLibrary given, which should be moved to another (development-) application. This is tested with Emsrv, not with file connections.
- Code: Select all
Application create: #WindowsStandbyWakeUpApp with:
(#( PlatformWidgets)
collect: [:each | Smalltalk at: each ifAbsent: [
Application errorPrerequisite: #WindowsStandbyWakeUpApp missing: each]])!
WindowsStandbyWakeUpApp becomeDefault!
Application subclass: #WindowsStandbyWakeUpApp
instanceVariableNames: ''
classVariableNames: 'LastPowerMessage OldWmPowerbroadcastSelector '
poolDictionaries: 'PlatformConstants '!
WindowsStandbyWakeUpApp becomeDefault!
!OSWidget publicMethods !
wmPowerbroadcast: wParam with: lParam
"Notifies every OSShell that a power-management event has occurred.
wParam
0 = Query Suspend - PBT_APMQUERYSUSPEND Return TRUE to grant the request to suspend. To deny the request, return BROADCAST_QUERY_DENY
4 = Suspend = Standy-by Modus (PBT_APMSUSPEND)
7 = Wake up by user (PBT_APMRESUMESUSPEND)
18 = Wake up general (PBT_APMRESUMEAUTOMATIC)
see http://msdn.microsoft.com/en-us/library/aa373247(VS.85).aspx"
^WindowsStandbyWakeUpApp wmPowerbroadcast: wParam with: lParam! !
OSWidget categoriesFor: #'wmPowerbroadcast:with:' are: #('AbtRun-Internal')!
!SubApplication class publicMethods !
fallAsleep
"The default behavior for the receiver before the computer
goes to stand-by (sleep) modus is to do nothing.
This is called each time before the computer goes to stand-by (sleep) modus"!
wakeUp
"The default behavior for the receiver after the computer is woken up
from stand-by is to do nothing.
This is called each time the computer is woken up from stand-by modus" ! !
SubApplication class categoriesFor: #'fallAsleep' are: #('EM-API')!
SubApplication class categoriesFor: #'wakeUp' are: #('EM-API')!
!WindowsStandbyWakeUpApp class publicMethods !
loaded
"install messageselector for handling the power-management event"
| selector |
"keep a possible previous message-selector for WmPowerbroadcast for uninstall"
selector := OSWidget eventTableAt: WmPowerbroadcast.
selector ~= #wmPowerbroadcast:with: ifTrue: [OldWmPowerbroadcastSelector := selector].
OSWidget eventTableAt: WmPowerbroadcast put: #wmPowerbroadcast:with:
!
reconnectToDefaultLibrary
"After the computer is woken up from stand-by
reconnect to the default libary if the connection is broken during stand-by time"
| libraryClass emLibrary |
libraryClass := Smalltalk at: #EmLibrary ifAbsent: [^self].
emLibrary := libraryClass default.
(emLibrary isNil or: [emLibrary isActuallyOpen not]) ifTrue: [^Transcript cr; show: 'Wake-up from standby. Library not connected.'].
"Check broken emsrv connection"
emLibrary primitiveQueryServerType: emLibrary fileId.
emLibrary errorCode = 0 ifTrue: [^self "still connected"]. "242 seems to be the errorCode for lost emsrv-connections after wake-up"
"reconnect"
emLibrary := libraryClass startUp.
Transcript cr; show: 'Library reconnected after wake-up to ', emLibrary fullName!
removing
"reset EventTable to previous state"
OSWidget eventTableAt: WmPowerbroadcast put: OldWmPowerbroadcastSelector!
wakeUp
"example: after the computer is woken up from stand-by
reconnect to the default Libary when in development"
"System isRuntime ifTrue: [^self].
self reconnectToDefaultLibrary"!
wmPowerbroadcast: wParam with: lParam
"Notifies every OSShell that a power-management event has occurred.
wParam
0 = Query Suspend - PBT_APMQUERYSUSPEND Return TRUE to grant the request to suspend. To deny the request, return BROADCAST_QUERY_DENY
4 = Suspend = Standy-by Modus (PBT_APMSUSPEND)
7 = Wake up by user (PBT_APMRESUMESUSPEND)
18 = Wake up general (PBT_APMRESUMEAUTOMATIC)
see http://msdn.microsoft.com/en-us/library/aa373247(VS.85).aspx"
"execute the message only once (while MSWindows is sending the message to every OSShell in the image)"
wParam = LastPowerMessage ifTrue: [^1].
LastPowerMessage := wParam.
wParam = 18 ifTrue: [
"PBT_APMRESUMEAUTOMATIC"
System loadedSubApplications do: [:app | app wakeUp] ].
wParam = 4 ifTrue: [
"PBT_APMSUSPEND"
System loadedSubApplications do: [:app | app fallAsleep] ].
^1! !
WindowsStandbyWakeUpApp class categoriesFor: #'loaded' are: #('initialize - release')!
WindowsStandbyWakeUpApp class categoriesFor: #'reconnectToDefaultLibrary' are: #('events')!
WindowsStandbyWakeUpApp class categoriesFor: #'removing' are: #('initialize - release')!
WindowsStandbyWakeUpApp class categoriesFor: #'wakeUp' are: #('events')!
WindowsStandbyWakeUpApp class categoriesFor: #'wmPowerbroadcast:with:' are: #('events')!
WindowsStandbyWakeUpApp initializeAfterLoad!
WindowsStandbyWakeUpApp loaded!
Installation: Copy the code to an empty workspace, select all and execute fileIn.
The code is not prepared for packaging and not tested in Runtime. WakeUp and reconnectToDefaultLibrary works fine in my 7.0 development image. It should work with all Versions, even 8.0.
Juergen