<commit_before>package main

import (
    "log"
    "strings"
    "errors"

    "code.google.com/p/go.net/websocket"
)

const listenAddr = "localhost:4000"

type Socket struct {
    ws     *websocket.Conn
    UID    string
    buff   chan *Message
    done   chan bool
    Server *Server
}

func (this Socket) Close() error {
    this.Server.Store.Remove(this.UID)
    this.done <- true
    
    return nil
}

func Authenticate(sock *Socket) error {
    var message Message
    err := websocket.JSON.Receive(sock.ws, &message)

    log.Println(message.Event)
    if err != nil {
        return err
    }
    
    if strings.ToLower(message.Event) != "Authenticate" {
        return errors.New("Error: Authenticate Expected.\n")
    }
    
    UID, ok := message.Body["UID"].(string)
    if !ok {
        return errors.New("Error on Authenticate: Bad Input.\n")
    }
    
    log.Printf("saving UID as %s", UID)
    sock.UID = UID
    sock.Server.Store.Save(UID, sock)
    
    log.Printf("saving UID as %s", sock.UID)
    
    return nil
}

func listenForMessages(sock *Socket) {
    <commit_msg>string to lower means this should be lower too. derp<commit_after>package main

import (
    "log"
    "strings"
    "errors"

    "code.google.com/p/go.net/websocket"
)

const listenAddr = "localhost:4000"

type Socket struct {
    ws     *websocket.Conn
    UID    string
    buff   chan *Message
    done   chan bool
    Server *Server
}

func (this Socket) Close() error {
    this.Server.Store.Remove(this.UID)
    this.done <- true
    
    return nil
}

func Authenticate(sock *Socket) error {
    var message Message
    err := websocket.JSON.Receive(sock.ws, &message)

    log.Println(message.Event)
    if err != nil {
        return err
    }
    
    if strings.ToLower(message.Event) != "authenticate" {
        return errors.New("Error: Authenticate Expected.\n")
    }
    
    UID, ok := message.Body["UID"].(string)
    if !ok {
        return errors.New("Error on Authenticate: Bad Input.\n")
    }
    
    log.Printf("saving UID as %s", UID)
    sock.UID = UID
    sock.Server.Store.Save(UID, sock)
    
    log.Printf("saving UID as %s", sock.UID)
    
    return nil
}

func listenForMessages(sock *Socket) {
    
{'fraction_non_alphanumeric': 0.11957008508732647, 'fraction_numerical': 0.0035826242722794446, 'mean_word_length': 2.329359165424739, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1136722', 'n_tokens_mistral': 782, 'n_tokens_neox': 752, 'n_words': 185}