Results 1 to 4 of 4

Thread: Multiple Users in Chat Server

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37

    Post

    anyone????

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    If you post code that is too long, many won't read it and will therefore not reply. Try posting just the important bits...asking people to debug entire programs usually results in no response..

    Good luck!

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37

    Post

    Oh sorry...actually I just wanted to know what the code was to add multiple users....i just put my code in so ppl would know what kind of server it was...

    thanks anyway

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2000
    Posts
    37

    Post

    Hi, I made chat server/client program.

    I would like to know how to get multiple users to chat at once in the program. So far the last user to connect, get's the message not everyone.

    I'm posting the whole code for the chat server.

    PS: I got my program to run in the system tray

    Dunno how this will show up...

    // Code starts here
    Dim num As Integer
    Dim intMax As Integer


    Private Sub cmdSend_Click()
    Winsock(intMax).SendData (txtSend.Text + vbNewLine)
    txtSend.Text = ""
    End Sub

    Private Sub Form_Load()
    Dim counter As Integer
    ' this code is to show the form in the system tray
    'the form must be fully visible before calling Shell_NotifyIcon
    Me.Show
    Me.Refresh
    With nid
    .cbSize = Len(nid)
    .hwnd = Me.hwnd
    .uId = vbNull
    .uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
    .uCallBackMessage = WM_MOUSEMOVE
    .hIcon = Me.Icon
    .szTip = "mAdD CHAT SERVER" & vbNullChar
    End With
    Shell_NotifyIcon NIM_ADD, nid

    ' Set the LocalPort property to an integer.
    ' Then invoke the Listen method.
    intMax = 0
    Winsock(0).LocalPort = 1001
    Winsock(0).Listen


    End Sub

    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'this procedure receives the callbacks from the System Tray icon.
    Dim Result As Long
    Dim msg As Long
    'the value of X will vary depending upon the scalemode setting
    If Me.ScaleMode = vbPixels Then
    msg = X
    Else
    msg = X / Screen.TwipsPerPixelX
    End If
    Select Case msg
    Case WM_LBUTTONUP '514 restore form window
    Me.WindowState = vbNormal
    Result = SetForegroundWindow(Me.hwnd)
    Me.Show
    Case WM_LBUTTONDBLCLK '515 restore form window
    Me.WindowState = vbNormal
    Result = SetForegroundWindow(Me.hwnd)
    Me.Show
    ' if button is clicked then show popUp menu
    Case WM_RBUTTONUP '517 display popup menu
    Result = SetForegroundWindow(Me.hwnd)
    Me.PopupMenu Me.mPopUpSys
    End Select
    End Sub


    Private Sub Winsock_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    Dim counter As Integer
    Dim num As Integer

    If Index = 0 Then
    intMax = intMax + 1
    Load Winsock(intMax)
    Winsock(intMax).LocalPort = 0
    Winsock(intMax).Accept requestID
    End If

    End Sub
    Private Sub Form_Resize()
    'this is necessary to assure that the minimized window is hidden
    If Me.WindowState = vbMinimized Then Me.Hide
    End Sub
    Private Sub mPopExit_Click()
    'called when user clicks the popup menu Exit command
    Unload Me
    End Sub
    Private Sub mPopRestore_Click()
    'called when the user clicks the popup menu Restore command
    Me.WindowState = vbNormal
    Result = SetForegroundWindow(Me.hwnd)
    Me.Show
    End Sub

    Private Sub Form_Unload(Cancel As Integer)
    'this removes the icon from the system tray
    Shell_NotifyIcon NIM_DELETE, nid
    End Sub

    Private Sub Winsock_DataArrival(Index As Integer, ByVal bytesTotal As Long)
    Dim remIP As String
    Dim counter As Integer

    remIP = Winsock(Index).RemoteHostIP

    ' Declare a variable for the incoming data.
    ' Invoke the GetData method and set the Text
    ' property of a TextBox named txtOutput to
    ' the data.
    Dim strData As String
    For counter = 0 To num
    Winsock(Index).GetData strData
    txtOut.Text = txtOut.Text + remIP + " : " + strData
    txtOut.Refresh
    Next
    End Sub

    // code ends here

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width