Private Sub WebSocket_Disconnected
Log("Disconnected")
If ABMPageId <> "" Then CallSubDelayed3(ChatShared, "Disconnected", Me, ABMPageId)
End Sub
public Sub BuildTheme()
' start with the base theme defined in ABMShared
theme.Initialize("pagetheme")
theme.AddABMTheme(ABMShared.MyTheme)
' add additional themes specific for this page
theme.AddChatTheme("myChat")
theme.Chat("myChat").AddBubble("server")
theme.Chat("myChat").Bubble("server").Color = ABM.COLOR_BLACK
theme.Chat("myChat").Bubble("server").TextColor = ABM.COLOR_WHITE
theme.Chat("myChat").AddBubble("me")
theme.Chat("myChat").Bubble("me").Color = ABM.COLOR_LIGHTBLUE
theme.Chat("myChat").Bubble("me").TextColor = ABM.COLOR_WHITE
theme.Chat("myChat").AddBubble("them")
theme.Chat("myChat").Bubble("them").Color = ABM.COLOR_GREY
theme.Chat("myChat").Bubble("them").ColorIntensity = ABM.INTENSITY_LIGHTEN2
theme.Chat("myChat").Bubble("them").TextColor = ABM.COLOR_BLACK
End Sub
public Sub ConnectPage()
' connecting the navigation bar
' init all your own variables (like a List, Map) and add your components
Dim chat As ABMChat
chat.Initialize(page, "conversation",600, 450, 255, "mychat")
chat.AddBubble("Server", "I'm Server, what is your name?", "The Server", "server", "server")
page.Cell(1,1).AddComponent(chat)
Dim ChatInput As ABMInput
ChatInput.Initialize(page, "ChatInput", ABM.INPUT_TEXT, "", False, "")
ChatInput.PlaceHolderText = "Type your message here...."
ChatInput.RaiseChangedEvent = True
page.Cell(2,1).AddComponent(ChatInput)
' refresh the page
page.Refresh
' Tell the browser we finished loading
page.FinishedLoading
' restoring the navigation bar position
page.RestoreNavigationBarPosition
End Sub
Sub ChatInput_Changed(value As String)
If ChatShared.HasIdentified(ABMPageId) Then
CallSubDelayed3(ChatShared, "IsTyping", ABMPageId, value)
End If
End Sub
Sub ChatInput_EnterPressed(value As String)
DateTime.TimeFormat = "HH:mm"
If ChatShared.HasIdentified(ABMPageId) Then
Dim bubble As ABMChatBubble
bubble.Initialize(ChatName, value, ChatName & " " & DateTime.Time(DateTime.Now), "me", "them")
CallSubDelayed3(ChatShared, "NewMessage", ABMPageId, bubble)
CallSubDelayed3(ChatShared, "IsTyping", ABMPageId, "")
Else
If value = "" Then Return
If ChatShared.AvoidDuplicates.ContainsKey(value.ToLowerCase) Then
Dim chat As ABMChat = page.Component("conversation")
chat.AddBubble("Server", "Sorry, but " & value & " is already taken!", "The Server", "server", "server")
chat.Refresh
Else
ChatName = value
ChatShared.AvoidDuplicates.Put(value.ToLowerCase, value)
Dim chat As ABMChat = page.Component("conversation")
chat.SetMyFrom(ChatName)
chat.AddBubble("Server", "Welcome to ABMChat " & ChatName & "!", "The Server", "server", "server")
chat.Refresh
CallSubDelayed3(ChatShared, "NewConnection", Me, ABMPageId)
End If
End If
Dim ChatInput As ABMInput = page.Component("ChatInput")
ChatInput.Text = ""
ChatInput.Refresh
End Sub
public Sub NewMessage(bubble As ABMChatBubble)
Dim chat As ABMChat = page.Component("conversation")
chat.AddBubble2(bubble)
chat.Refresh
chat.ScrollToBottom ' scroll to the end of the chat
End Sub
public Sub IsTyping(pageID As String, typeBool As Boolean)
Dim chat As ABMChat = page.Component("conversation")
If pageID <> ABMPageId Then
If typeBool = False Then
chat.ThemAreTyping(False, "") 'hide the 'is typing' bubble
Else
chat.ThemAreTyping(True, "") ' show the 'is typing' bubble if not yet shown
End If
chat.Refresh
chat.ScrollToBottom ' scroll to the end of the chat
End If
End Sub
public Sub CurrentConversation(LastMessages As List)
If LastMessages.Size > 0 Then
Dim chat As ABMChat = page.Component("conversation")
chat.SetConversation(LastMessages)
chat.Refresh
chat.ScrollToBottom ' scroll to the end of the chat
End If
End Sub